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.

Repeated Tag usage

February 06, 2009 6:58pm

Subscribe [1]
  • #1 / Feb 06, 2009 6:58pm

    Mirage

    273 posts

    HI - still new to EE and the templating system is having me lose some hair… since I’m used to just working with CI/PHP.

    I see a lot of repeat usage of the weblog:entries tag to get at information of an entry in different parts of a document. Is that the intended way of doing it?

    In CI I would load a weblog entry once and then just reference it in the view (template) or nested sub-templates wherever I need it. Here it feels really verbose in the template logic to make the call over and over again.

    My current case is such that I use the pages module and I have a handful of templates to which the content can be rendered. As such I open the weblog:entries container once at the top of the template and close it at the bottom of the template.

    Questions:
    Are there performance concerns regarding repeat access to weblog:entries with the same parameters?

    Is there a way to reference the ‘current’ entry in a template variable so that it can be referenced?


    Thanks,
    Juergen

  • #2 / Feb 06, 2009 7:36pm

    Mirage

    273 posts

    A quick reply to myself -

    Some more research reveals that any plugin call {exp:plugin:method} creates a new instance of the plugin. So repeated usage without external or global memory caching will cause excessive class construction/destruction. Not so happy about that…

    I hope someone can show me I’m wrong.

    Juergen

  • #3 / Feb 07, 2009 3:02pm

    Greg Aker

    6022 posts

    Greetings Juergen:

    As far as repeated weblog entries templates, I would definitely be disabling as much as I can on each tag.

    With caching, please see this page

    -greg

  • #4 / Feb 07, 2009 3:31pm

    Mirage

    273 posts

    Thank you Greg -

    Yes I’m beginning to see these things. Adapting to EE when you’re used to CI is definitely an uphill battle. I feel much less in control… I get that it’s a page/content based approach and that limitations come with that. But it does feel like years of adaption of DRY principles, abstraction and such go straight out the window.

    I have the fortunate opportunity to look at the implementation of some bigger EE projects to set ‘how they did it’. This helps me to embrace, rather than fight the EE way of doing things over the hump and while I see a benefit on the business side of things, it’s clearly not easy for this coder…

    Juergen

  • #5 / Feb 08, 2009 2:03pm

    Greg Aker

    6022 posts

    Juergen:

    With EE, the more tags you have calling to the database, the more MySQL overhead you have.  Just like making 10 model calls in your controller is more overhead than 3. 

    As for using DRY principles, I would look at User Defined Global Variables, and definitely the Fresh Variables module.

    Regards,

    -greg

  • #6 / Feb 08, 2009 2:29pm

    Mirage

    273 posts

    Greg -

    Thanks again, all well understood.  So that means I’ll employ principles in my plugins that will use some sort of shared cache that survives instances to avoid excessive querying…

    Cheers,
    Juergen

  • #7 / Feb 08, 2009 2:42pm

    Greg Aker

    6022 posts

    I’m glad that got you squared away.  To see how caching can be employed in plugins, take a look at the Twitter Timeline plugin.

    Closing this thread out, but if anything else comes up, please don’t hesitate to start a new thread.

    -greg

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

ExpressionEngine News!

#eecms, #events, #releases