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.

assign variables

October 14, 2008 4:08am

Subscribe [3]
  • #1 / Oct 14, 2008 4:08am

    Mikeey

    3 posts

    Hi,

    How do I assign a variable in a weblog?

    {assign_variable:variable_name="value"}

    This is what I want to do:

    {exp:weblog:entries weblog="products"}
    {categories}
        {variable_name} = {category_id}
    {/categories}
    {/exp:weblog:entries}

    And later down in the template i want to use the category_id stored in {variable_name} in another weblog as a category parameter like this:

    {exp:weblog:entries weblog="external_articles" category="{variable_name}"}

    All I want is to know what category the product belongs to and then show all external articles the belong to the same category.

    Thanks in advance!

  • #2 / Oct 14, 2008 4:34am

    Ingmar

    29245 posts

    This is what I want to do:

    {exp:weblog:entries weblog="products"}
    {categories}
        {variable_name} = {category_id}
    {/categories}
    {/exp:weblog:entries}

    You can’t use EE variables like that. They are more like constants, really, assigned once at the beginning of the execution and can’t be changed at runtime. If you really need that functionality, you’ll probably have to use PHP.

    All I want is to know what category the product belongs to and then show all external articles the belong to the same category.

    Why, Related Category Mode seems like a perfect fit.

  • #3 / Oct 14, 2008 4:38am

    Mikeey

    3 posts

    Thanks. related_categories_mode did the thing!

    Very fast response! I am impressed!

  • #4 / Oct 14, 2008 5:07am

    Ingmar

    29245 posts

    Glad to hear that solved the issue for you 😊 Don’t hesitate to post again, if you need help.

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

ExpressionEngine News!

#eecms, #events, #releases