We use cookies to improve your experience. No personal information is gathered and we don't serve ads. Cookies Policy.

ExpressionEngine Logo ExpressionEngine
Features Pricing Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University
Log In or Sign Up
Log In Sign Up
ExpressionEngine Logo
Features Pro new Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University Blog
  • Home
  • Forums

Parse Order is killing me... perhaps there's a different path to take?

Development and Programming

mark186282's avatar
mark186282
290 posts
13 years ago
mark186282's avatar mark186282

Happy New Year! Here’s the situation I’m in and what I’m trying to solve - if anyone might have some ideas, I would really appreciate it.

Channel #1 is a list of “bands”. The url_title of each band also corresponds to a subdomain used on the site

Example: entry_id = 1, title “Grumpy Cats”, url_title: grumpycats entry_id = 2, title “Three Thumbs Too Many”, url_title: threethumbs

Channel #2 is a list of “songs”

Example entry_id = 11, title “Hairballs and sour mice”, which_band=(grumpy cats) entry_id = 22, title “Hitchhiking made easy”, which_band=(three thumbs too many)

If I go to:

grumpycats.example.com, I want to show entry 11

of course, if I go to

threethumbs.example.com, I want to show entry 22

I created a plugin (subdomainer) that returns the subdomain based on the current URL… but it gets parsed AFTER the channel entries tag is parsed (I even tried the parse=’inward’ directive in the plugin tag)…

{exp:subdomainer} // returns "threethumbs"

This works:

{exp:channel:entries channel='songs' dynamic='no' search:band='threethumbs'}
....
{/exp:channel:entries}

This does NOT work:

{exp:channel:entries channel='songs' dynamic='no' search:band='{exp:subdomainer}'}
....
{/exp:channel:entries}

………..

Is there a method of generating a global variable that I can use in my templates that is parsed very early in the process (like when segment variables are parsed?). I’m doing my best to keep any PHP out of my template. I’ve got a team of designers and project managers that would like me to keep is as clean as possible in the templates themselves.

something like this:

{exp:channel:entries channel='songs' dynamic='no' search:band='{GLOBAL_SUBDOMAIN_VAR}'}
....
{/exp:channel:entries}

Thanks in advance for any ideas…

       
mark186282's avatar
mark186282
290 posts
13 years ago
mark186282's avatar mark186282

I’ve got it working, although there’s probably a way that would be less overhead…

here’s my solution:

{exp:subdomainer parse='inward'}
     {exp:channel:entries channel='songs' dynamic='no' search:band='{subdomain}'}
     ....
     {/exp:channel:entries}
{/exp:subdomainer}
       
Gareth Davies's avatar
Gareth Davies
491 posts
13 years ago
Gareth Davies's avatar Gareth Davies

Check out Low Variables and particularly the early parse option.

gotolow.com/addons/low-variables

       
mark186282's avatar
mark186282
290 posts
13 years ago
mark186282's avatar mark186282

Thanks for the info.

As far as I understand it, Low Variables would work if the information was static and not being gleaned from the URL (the subdomain, in particular)

I’ve got it working with my plugin as described above. I’ll leave well-enough alone and keep my eyes open for solutions with less overhead.

Thanks again for the assist.

-Mark

       
Adam Khan's avatar
Adam Khan
319 posts
13 years ago
Adam Khan's avatar Adam Khan

Did you try parse=”inward” as a parameter in the channel:entries tag?

       

Reply

Sign In To Reply

ExpressionEngine Home Features Pro Contact Version Support
Learn Docs University Forums
Resources Support Add-Ons Partners Blog
Privacy Terms Trademark Use License

Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.