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.

Pass a Variable in a Link to use as a Template Conditional?

October 26, 2011 11:25pm

Subscribe [2]
  • #1 / Oct 26, 2011 11:25pm

    bcrabtree

    60 posts

    Hi,

    I have a situation where I would like to create two global variables:
    {grid_view}
    {orderby_popular}

    Then pass those variables to a template in a link in order to create different layouts and orderby views of the same data. WITHOUT USING SEGMENTS VARIABLES. The combination of both global variable conditions with category and tag url segments makes it way to complicated to use segment variables.

    For example if I have a link:

    <a href="http://{path=template_group/template}">Grid View</a>

    With that link I would like to set {grid_view} to either true or false in the template that I’m linking too, same thing for the {orderby_popular} variable.

    In my template I envision something like this:

    {if grid_view != "true" && orderby_popular != "true"}
        Show list view with default ordering
    {if:elseif grid_view != "true" && orderby_popular == "true"}
        Show list view with popular entry ordering
    {if:elseif grid_view == "true" && orderby_popular != "true"}
        Show grid view with default ordering
    {if:else}
        Show grid view with popular entry ordering
    {/if}

    Is that at all possible?

    I tried another solution using url segments and dynamic parameters but I need the chosen options to work with pagination…

    Note: I’m using Solspace Favorites to set entry popularity.

  • #2 / Oct 27, 2011 2:40pm

    bcrabtree

    60 posts

    Bump

  • #3 / Oct 27, 2011 3:49pm

    Kevin Smith

    4784 posts

    Hi Bryan,

    If dynamic parameters won’t work for you because you need to be able to paginate, then the only way I can think of to accomplish what you’re looking to do is to set variables for a particular user’s session that hold between page loads. I found one add-on that does just such a thing: Session Variables. You may want to peruse Devot://ee for other options.

  • #4 / Oct 27, 2011 4:14pm

    bcrabtree

    60 posts

    Thanks Kevin,

    Session Variables may be the solution I’m looking for. I’ll try it out and see if it solves my problem.

    Cheers,
    Bryan

  • #5 / Oct 29, 2011 7:04am

    Mark Bowen

    12637 posts

    Hi Bryan,

    As what you are trying to do is going against the way ExpressionEngine normally works by not using URI segments and there’s nothing built-in to ExpressionEngine in order to allow you to do this sort of thing I’m going to move this thread down to the Community Help forums incase someone there has any ideas on this one.

    Thanks,

    Mark

  • #6 / Oct 29, 2011 4:00pm

    bcrabtree

    60 posts

    No worries,

    Setting up Session Variables was the perfect solution for what I was trying to accomplish. Thanks for the point in the right direction.

    Cheers,
    Bryan

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

ExpressionEngine News!

#eecms, #events, #releases