- Posts: 438
COMMUNITY FORUM
- Forum
- K2 Community Forum
- English K2 Community
- Can you echo the category alias within the category override
Can you echo the category alias within the category override
- Joe Campbell
-
Topic Author
- Offline
- Platinum Member
Less
More
9 years 10 months ago #145264
by Joe Campbell
Can you echo the category alias within the category override was created 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
-
- Offline
- Platinum Member
Less
More
- Posts: 15920
9 years 10 months ago - 9 years 10 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
This way you can see all of the available options.
To print them use:
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.
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.
Last edit: 9 years 10 months ago by Krikor Boghossian.
Please Log in or Create an account to join the conversation.
- Joe Campbell
-
Topic Author
- Offline
- Platinum Member
Less
More
- Posts: 438
9 years 10 months ago #145287
by Joe Campbell
Replied by Joe Campbell on topic Can you echo the category alias within the category override
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.
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
-
- Offline
- Platinum Member
Less
More
- Posts: 15920
9 years 10 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.
If you use the same alias, K2 cannot differentiate these categories (same as WP). A category needs a distinct alias.
Please Log in or Create an account to join the conversation.
- Joe Campbell
-
Topic Author
- Offline
- Platinum Member
Less
More
- Posts: 438
9 years 10 months ago #145323
by Joe Campbell
Replied by Joe Campbell on topic Can you echo the category alias within the category override
What code would I use for the following...
<? if url path == 'category-1/subcategory-a' ?>
Hello World
<?php endif; ?>
<? if url path == 'category-1/subcategory-a' ?>
Hello World
<?php endif; ?>
Please Log in or Create an account to join the conversation.
- Krikor Boghossian
-
- Offline
- Platinum Member
Less
More
- Posts: 15920
9 years 10 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 .
Please Log in or Create an account to join the conversation.
- Forum
- K2 Community Forum
- English K2 Community
- Can you echo the category alias within the category override