0

ExpressionEngine 3.5.10.

I am outputting a specific list of categories (category_group="1") from a channel of training courses (channel="training"). Followed by the list of courses assigned to that category. I have then used the Grid type field to store some details of when particular courses run, their price, etc. For example:

{exp:channel:categories category_group="1" style="linear" channel="training" show_empty="no"}


    {exp:channel:entries category="{category_id}"}

        <!-- Output name of course -->

        {training_booking_options}
            <!-- Output options for this course, e.g. price -->
            <a href="{path='contact-us'}">contact us</a>
        {/training_booking_options}

    {/exp:channel:entries}

{/exp:channel:entries}

Wherever I use {path=""} it is outputting the category URL path in the URL. For example: <a href="{path='contact-us'}">contact us</a> gives URL's such as:

I want the URL to be what I've put, i.e. http://dev.domain/contact-us regardless of the category it's within at the time the link is output.

Is this possible, or should I just abandon using path= and hardcode it like <a href="/contact-us">contact us</a>?

I don't want to use any of the "category name in URL" features for this particular section of the website. But there are other sections where I do want to use it. So I don't want a solution which disables it for the entire site!

2
  • 1
    I never use path, always use relative links, always. Commented Sep 22, 2017 at 4:59
  • I have to agree with that. I don't think {path=} does anything useful anyway. All it seems to do is prepend the base URL....to a URL string which you still have to define anyway! Doesn't seem very useful as obviously you can output the base URL with PHP anyway.
    – Andy
    Commented Sep 22, 2017 at 9:43

1 Answer 1

-1

The only way to do it I think will be to construct the URL from components. (as is clear from answer above) I'm not so clear on what your setup is, but something like this might work:

{exp:channel:categories category_group="1" style="linear" channel="training" show_empty="no"}


    {exp:channel:entries category="{category_id}"}

        <!-- Output name of course -->

        {training_booking_options}
            <!-- Output options for this course, e.g. price -->
            <a href="{path='SITE_INDEX'}/contact-us/{category_url_title}">contact us</a>
        {/training_booking_options}

    {/exp:channel:entries}

{/exp:channel:entries}

HTH

2
  • Unfortuantely this doesn't work. Did you try it? The URL's end up with the channel entry slug in them (as opposed to the category slug). So it's still not /contact-us, it's /contact-us/channel-entry-url. I don't think it's possible in EE so just going to hardcode a relative link.
    – Andy
    Commented Sep 21, 2017 at 8:28
  • ahah - I misunderstood your question :] - or rather what you were getting from the categories tag. The only way to do it I think will be to construct the URL from components. (as is clear from answer above) I'm not so clear on what your setup is, but something like this might work: <a href="{path='SITE_INDEX'}/contact-us/{category_url_title}">{category_name}</a> HTH Commented Sep 21, 2017 at 9:24

Your Answer

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

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