Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8431515
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T05:52:33+00:00 2026-06-10T05:52:33+00:00

I don’t even know if I’m asking for the right thing. What I have

  • 0

I don’t even know if I’m asking for the right thing. What I have is a list of categories and those categories will be links to filter items. Here’s what I’m starting with:

{foreach from=$items item=entry}
{strip}
    {foreach from=$entry->categories item='one_category'}
         {foreach from=$categories item='one'}
              {if $one_category.name == $one.name}
                  {$one.name}    
                  {$one.name|munge_string_to_url} 
              {/if}
         {/foreach}
     {/foreach}
{/strip}
{/foreach}

Here’s a better version:

So this lists out every instance used on a page. The intention is to list the instance 1x, if there is an instance.

  <ul>
    <li><a class="active" href="#" data-filter="*">All</a></li>
    {foreach from=$items item=entry}
    {foreach from=$categories item='one'} 
     <li><a href="#" data-filter=".{$one.name|munge_string_to_url}">{$one.name}</a></li>
    {/foreach}{/foreach}
  </ul>

This shows all the items but it’s not correct, if there are 20 articles assigned to one category, it lists it 20 times, if there are 5 articles assigned to one category it will list it 5 times. I just want one each for each matching string. Not a clue as to what to do. Thank you for any insight you can provide.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T05:52:34+00:00Added an answer on June 10, 2026 at 5:52 am

    Let’s try this.

    <ul>
        <li><a class="active" href="#" data-filter="*">All</a></li>
        {assign var="tempCat" value=""}
        {foreach from=$items item=entry}
            {if $entry->categories} 
            {strip}
                {foreach from=$entry->categories item='category'}
                    {if !$tempCat|strstr:$category.name} 
                        <li><a href="#" data-filter=".{$category.name|munge_string_to_url}">{$category.name}</a></li>
                        {assign var="tempCat" value=$tempCat|cat:$category.name}
                    {/if}
                {/foreach}
            {/strip}
            {/if}
        {/foreach}
    </ul>
    

    Basically, the idea is to keep a record of categories you’ve already added to the list and not add them again. I do this through $tempCat which starts as nothing and concatenates any category that’s not in it. So subsequent checks see the category is already added and skips it.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Don't know if this is the right place to ask this, but I will
Don't know if I worded the question right, but basically what I want to
Don't know if anyone can help me with this or if it's even possible.
Don't know if this is possible, but I have some code like this: val
Don't know if this has been answered before. Have custom routes to users. If
Don't know why but I can't find a solution to this. I have 3
Don't know the term for the red validation border, does it have one? I
don't know better title for this, but here's my code. I have class user
Don't know if it's stupid or reasonable question. I have methods which returns float/int
don't know if the title describes anything about what I'm trying to say but

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.