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.

Is it possible to select a weblog by URL

February 03, 2011 4:39pm

Subscribe [3]
  • #1 / Feb 03, 2011 4:39pm

    stevealfa

    11 posts

    Is this type of expression possible?

    exp:weblog:entries weblog=“segment_2”

    or is there another way that I can automatically select a weblog by url

    eg if url = mydomain.com/tennis then weblog = tennis

    Thanks Steve

  • #2 / Feb 04, 2011 9:49am

    Sue Crocker

    26054 posts

    Hi, stevealfa.

    Sure. You’d need to have your weblog named the same thing as your segment name.

    So you’d do something like this:

    {exp:weblog:entries weblog="{segment_2}"}
    ...
    {/exp:weblog:entries}

    Does that help?

  • #3 / Feb 04, 2011 10:33am

    stevealfa

    11 posts

    Hi Sue,

    That’s great - works exactly how I want.

    Also I found one of your other posts about embedded variables which will help me when the weblog does not match the url eg

    {embed="globals/_master" section_weblog="football"}

    and then in the _master template

    {exp:weblog:entries weblog="{embed:section_weblog}"}
    ...
    {/exp:weblog:entries}

    Thanks

    PS Thanks Greg for the reminder to use curly brackets - I have corrected the code above just in case someone tries to use it 😊

  • #4 / Feb 05, 2011 1:55pm

    Greg Salt

    3988 posts

    Hi Steve,

    Glad that Sue was able to help you with this. For your _master template example don’t forget that the embed variable has be to surrounded by curly braces. Please post back if required.

    Cheers

    Greg

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

ExpressionEngine News!

#eecms, #events, #releases