Keyword

Hidden only some tags

  • STEPHAN HERBY
  • STEPHAN HERBY's Avatar Topic Author
  • Offline
  • Premium Member
More
6 years 7 months ago - 6 years 7 months ago #163479 by STEPHAN HERBY
Hidden only some tags was created by STEPHAN HERBY
Hi,
here's something I'm trying to do :
On my items, I use tags that show some "business" concerned by the article so visitors can find easily all items talking about that or that business. Nothing extraordinary here, the code (that work well) is :
<?php if($this->item->params->get('itemTags') && count($this->item->tags)): ?>
<dt class="uk-text-small">Entreprise(s) citée(s)</dt>
<dd>
<ul class="uk-list">
<?php foreach ($this->item->tags as $tag): ?>
<li><a href="<?php echo $tag->link; ?>"><?php echo $tag->name; ?></a></li>
<?php endforeach; ?>
</ul>
</dd>
<?php endif; ?>
Today, i need 3 news tags for another fix on my homepage. I need this 3 tags to be never print on no pages, just a help for filter on my homepage. SO i have tried that code, with the ID of each tag :
<?php if($this->item->params->get('itemTags') && count($this->item->tags)): ?>
<dt class="uk-text-small">Entreprise(s) citée(s)</dt>
<dd>
<ul class="uk-list">
<?php foreach ($this->item->tags as $tag): ?>
<?php if (($tag == "532") || ($tag == 533) || ($tag == 534))
{

} else { ?>
<li><a href="<?php echo $tag->link; ?>"><?php echo $tag->name; ?></a></li>
<?php }
endforeach; ?>
</ul>
</dd>
<?php endif; ?>
I have even tried with the value of each tag (instead of the ID), but i can't get any result, tags are still printed. There's probably something wrong in my code, but as my knowledge in php are this poor, maybe some one could have an advice ? Thanks in advance...
Last edit: 6 years 7 months ago by STEPHAN HERBY.

Please Log in or Create an account to join the conversation.

  • Krikor Boghossian
  • Krikor Boghossian's Avatar
  • Offline
  • Platinum Member
More
6 years 7 months ago #163508 by Krikor Boghossian
Replied by Krikor Boghossian on topic Hidden only some tags
You are halfway there.

The check should be:
$tag->id === 532

or
$tag->id == 532

JoomlaWorks Support Team
---
Please search the forum before posting a new topic :)

Please Log in or Create an account to join the conversation.

  • STEPHAN HERBY
  • STEPHAN HERBY's Avatar Topic Author
  • Offline
  • Premium Member
More
6 years 7 months ago #163518 by STEPHAN HERBY
Replied by STEPHAN HERBY on topic Hidden only some tags
Hi Krikor, thank you very much for your efficient help! It works (with the "==") :-)

Please Log in or Create an account to join the conversation.

  • Krikor Boghossian
  • Krikor Boghossian's Avatar
  • Offline
  • Platinum Member
More
6 years 7 months ago #163520 by Krikor Boghossian
Replied by Krikor Boghossian on topic Hidden only some tags
You 're welcome Stephan :)
It might work with === but you will need to omit the quotes.
More info here: php.net/manual/en/language.operators.comparison.php

JoomlaWorks Support Team
---
Please search the forum before posting a new topic :)

Please Log in or Create an account to join the conversation.


Powered by Kunena Forum