0

I've got a page behind a login that I have various member groups set up for.

Depending on the member group, I want the link in the Downloads section to go to a different page: e.g. Contractors member group will go to /downloads/contractors, Students member group will go to /downloads/students etc.

When I use my global variable for {group_title} in my page, it outputs "Contractors". Ideally it should output "contractors" in my link because if a member group has more than one word my URL isn't valid.

I tried wrapping {group_title} in CE String but it just outputs "group_title" into my HTML without the braces.

Here's my code:

{exp:ce_str:ing url_title}{group_title}{/exp:ce_str:ing}

1 Answer 1

0

This is because user-defined global variabes are parsed after plugin and module tags. (See parse order.) So you're literally passing {group_title} to CE String.

Try setting {group_title} via a preload_replace variable instead, as those are processed just before plugin tags.

3
  • Thanks for the suggestion Derek but no joy. Am I right in thinking that it's too early in the parse order to output what I want from the tags now. It's just printing out 'group_title' inside my link. {preload_replace:member_group="{group_title}"} <nav class="nav--sidebar"> <ul class="nav__list"> {if logged_in} <li> <a href="{site_url}member/downloads/{exp:ce_str:ing url_title}{member_group}{/exp:ce_str:ing}">{group_title} Downloads</a> </li> <li> <a href="{path='logout'}">Log Out</a> </li> {/if}
    – StvCummins
    Commented Jan 15, 2015 at 15:31
  • Yeah, you'd have to set group title in a preload_replace variable, i.e. {preload_replace:group_title="Contractors"}. How exactly you'd setup the logic to do this will depend on how exactly you're determining what that value should be. Commented Jan 15, 2015 at 16:20
  • Thanks for all the suggestions Derek. I was over thinking this. A simple if check around the couple of headings & links that I want to change will suffice. It might work out at maybe 4 lines of code more but at least it's a simple solution to something that's not even a massive problem.
    – StvCummins
    Commented Jan 27, 2015 at 9:50

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.