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.

category setting as a reusable var

September 04, 2012 5:31pm

Subscribe [1]
  • #1 / Sep 04, 2012 5:31pm

    Marin Bikes

    45 posts

    Hi,

    I am looking for a way to have a category id stored in a variable that I can use in multiple places around the site. The reason, I am marking products with a model year using categories, when the model year changes I would like to be able to change 1 var and have it roll across the site.

    {exp:channel:entries channel="bike_families" dynamic="no" category="{current-product-year}&8" disable="member_data|category_fields|trackbacks|"}

    I would like to be able to call it in channel entries like above.

    Is this possible?

    Thanks,
    Cory

  • #2 / Sep 06, 2012 11:46am

    Lisa Wess

    20502 posts

    Hi, CG11 -

    Have you considered storing that information in a snippet?

  • #3 / Sep 06, 2012 1:32pm

    Marin Bikes

    45 posts

    That worked thank you. I am still a bit confused about when to use snippets 😊

  • #4 / Sep 07, 2012 3:46pm

    Kevin Smith

    4784 posts

    Let’s say you’ve got a chunk of code from several different templates that’s all exactly the same. It’d be great to have that chunk of code in one spot where it can be updated and those changes reflected in all the templates that hold that code, right? That’s exactly what Snippets are for. (They help you keep your template code DRY!)

  • #5 / Sep 07, 2012 3:52pm

    Marin Bikes

    45 posts

    Thanks Kevin, I am actually using Stash to acheive Dry development. It is very similar to Twig and Django which is where I came from but I am not sure the benefits to using snippets versus using embeds or stashing. I also find it kind of weird that I can’t put snippets into files.

    -Cory

  • #6 / Sep 10, 2012 3:01pm

    Dan Decker

    7338 posts

    Hey Cory,

    There are a few add-ons that let you save snippets as files too.

    Is there anything else I can assist you with?

    Cheers,

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

ExpressionEngine News!

#eecms, #events, #releases