ExpressionEngine CMS
Open, Free, Amazing

Thread

This is an archived forum and the content is probably no longer relevant, but is provided here for posterity.

The active forums are here.

correct usage of channel_short_name..?!

June 06, 2012 12:04pm

Subscribe [2]
  • #1 / Jun 06, 2012 12:04pm

    Birchman

    4 posts

    I am using Structure and all I want to do is grab the current pages channel so I dont have to deal with
    ugly, endless & repetitive ( if channel_short_name == “foo”} statments…

    you would think I can do this without an extra plugin like mx jumper or string or any other plugins.
    isnt there a way of “echoing” channel_short_name as just a variable ...?

    here’s what my situation looks like:

    site/index:

    {embed="embeds/html_maincontent" channel="{channel_short_name}" the_url_title="{structure:top:slug}"}

    embeds/html_maincontent

    {exp:channel:entries channel="{embed:channel}" url_title="{embed:the_url_title}" disable="categories|member_data|pagination" sort="asc" }

    so… WHY doesnt this work…help. anybody.
    do I have to drop more money on more addons to do something this simple 😠
    OR worse have my only option an ugly & needless series of if statements…

  • #2 / Jun 06, 2012 1:02pm

    Manoj Thomas

    185 posts

    Saw this in the docs - would it work?

    {structure:child_listing:short_name}

    The channel short name of a channel attached as a listing

  • #3 / Jun 06, 2012 1:46pm

    Birchman

    4 posts

    yep, for it works.
    I thought I could just pass the current channel as a custom embedded variable to the embedded template :\


    so {structure:child_listing:short_name} works but I will need to test more though because I’m not using listings ( at least yet )
    However it does get me the correct channel content & seems to work at the moment.

    What happened to that original tag to grab the current page’s channel?

    here’s what my current code looks like btw for anyone else out for future reference for whomever it may benefit:

    site/index

    {embed="embeds/html_maincontent" current_channel="{structure:child_listing:short_name}" mypet="cat" the_url_title="{structure:top:slug}"}

    embeds/html_maincontent:

    {exp:channel:entries channel="{embed:current_channel}" url_title="{embed:the_url_title}" pet="{embed:mypet}" disable="categories|member_data|pagination" sort="asc" } 
    The Current Channel as channel_short_name is {channel_short_name}
    The Current Channel as channel is {channel}
    The Current Channel as embed:current_channel is {embed:current_channel}
    The Current Channel as embed:channel is {embed:channel}
    My Pet as pet is {pet} 
    My Pet as embed:mypet is {embed:mypet} 
    Title as title is {title} 
    Title as url_title is {url_title}
    Title as embed:the_url_title is {embed:the_url_title}
    Pagebody as page_body is {page_body} 
    {/exp:channel:entries}

    Which returns:
    The Current Channel as channel_short_name is contact
    The Current Channel as channel is Contact
    The Current Channel as embed:current_channel is
    The Current Channel as embed:channel is
    My Pet as pet is {pet}
    My Pet as embed:mypet is cat
    Title as title is Contact
    Title as url_title is contact
    Title as embed:the_url_title is contact
    Pagebody as page_body is
    “WOOT Content is showing up!”

.(JavaScript must be enabled to view this email address)

ExpressionEngine News!

#eecms, #events, #releases