Keyword

Can you echo the category alias within the category override

  • Joe Campbell
  • Joe Campbell's Avatar Topic Author
  • Offline
  • Platinum Member
More
8 years 9 months ago #145264 by Joe Campbell
What code would I use to echo the current category and current category alias (from within the category.php override file)?

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

  • Krikor Boghossian
  • Krikor Boghossian's Avatar
  • Offline
  • Platinum Member
More
8 years 9 months ago - 8 years 9 months ago #145270 by Krikor Boghossian
Replied by Krikor Boghossian on topic Can you echo the category alias within the category override
Hello Joe,

You can use
<pre><?php var_dump($this->category); ?></pre>

This way you can see all of the available options.

To print them use:
<?php echo $this->category->name; ?>
<?php echo $this->category->alias; ?>

This method also work for the item, category item (and on).
Instead of category you should item or plain $this, depending on which file you are editing.

JoomlaWorks Support Team
---
Please search the forum before posting a new topic :)
Last edit: 8 years 9 months ago by Krikor Boghossian.

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

  • Joe Campbell
  • Joe Campbell's Avatar Topic Author
  • Offline
  • Platinum Member
More
8 years 9 months ago #145287 by Joe Campbell
Thanks @Krikor for ALWAYS being so helpful

How can I use the same category alias for multiple categories?
Do I need to go into the DB?

I receive the following message...

Notice: Duplicate title alias entry detected. A number has been appended to the existing title alias to avoid URL conflicts. Alternatively, you can simply edit the title alias to your liking, as long as it doesn't conflict with another item's title alias.

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

  • Krikor Boghossian
  • Krikor Boghossian's Avatar
  • Offline
  • Platinum Member
More
8 years 9 months ago #145292 by Krikor Boghossian
Replied by Krikor Boghossian on topic Can you echo the category alias within the category override
You 're welcome Joe :)

If you use the same alias, K2 cannot differentiate these categories (same as WP). A category needs a distinct alias.

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

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

  • Joe Campbell
  • Joe Campbell's Avatar Topic Author
  • Offline
  • Platinum Member
More
8 years 9 months ago #145323 by Joe Campbell
What code would I use for the following...

<? if url path == 'category-1/subcategory-a' ?>
Hello World
<?php endif; ?>

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

  • Krikor Boghossian
  • Krikor Boghossian's Avatar
  • Offline
  • Platinum Member
More
8 years 9 months ago #145333 by Krikor Boghossian
Replied by Krikor Boghossian on topic Can you echo the category alias within the category override
It would be better to check the category's id $this->category->id .

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