0

I don't understand what's happening. I'm using the gwcode categories addon to get the category of and entry id, it works well when the entry id is present:

   {exp:gwcode_categories group_id="6" entry_id="22" depth="1"}
                   {cat_name}
   {/exp:gwcode_categories}

But when i use the url_title_to_entry_id plugin there is a problem:

  {exp:gwcode_categories group_id="6"
               entry_id="{exp:url_title_to_entry_id url_title="{segment_2}"}
               parse="inward" depth="1"}

                         {cat_name}

     {/exp:gwcode_categories}

The two categories inside the group name (id=6) are displayed instead of the category associated to the entry.

{exp:url_title_to_entry_id url_title="{segment_2} used alone display the correct entry id , so i don't understand why all the categories inside the group name are displayed. What could be the problem?

Edited:

{exp:url_title_to_entry_id url_title="{segment_2} is not parsing the entry_id, so all the categories are displayed. How to parse a variable entry id, inside the gwcode categories?

2
  • 1
    You dont have a closing quote on your plugin. Dont know of that plugin but should use simgle quotes inside double quotes too. Apr 6, 2014 at 8:01
  • Hi Stuart, thanks !! Right, a closing quot is missing, but really exp:url_title_to_entry_id not is parsed inside an other parameter addon. I will reconsider a solution using the get post method, or in place to use the url title using the entry id in the segment, would be more easy to manage.
    – Stéphane
    Apr 6, 2014 at 14:05

1 Answer 1

1

Not familiar with that plugin but you can try…

IF you're calling the {exp:channel:entries} tag, you could simply place it inside that tag and it'll work fine.

If you need to have it outside the {exp:channel:entries} tag you could use Stash to record it like:

{exp:stash:set name="catid" parse_tags="yes" type="snippet" trim="yes"} {!-- Save as snippet --}
{exp:url_title_to_entry_id url_title="{segment_2}"}
{/exp:stash:set}

{exp:stash:parse} {!-- Forces to parse after stash:set --}
{exp:gwcode_categories group_id="6"
  entry_id="{catid}"
  parse="inward" depth="1"}
{cat_name}
{/exp:gwcode_categories}
{/exp:stash:parse}

This code is off-the-top and may or may not work 'as-is' but the theory is sound ;)

1
  • Stuart, thanks for your code example. It works fine, and really Stash is very powerful, for the moment i only know the bases, so I have to improve the Stash capabilities.
    – Stéphane
    Apr 8, 2014 at 12:49

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.