We use cookies to improve your experience. No personal information is gathered and we don't serve ads. Cookies Policy.

ExpressionEngine Logo ExpressionEngine
Features Pricing Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University
Log In or Sign Up
Log In Sign Up
ExpressionEngine Logo
Features Pro new Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University Blog
  • Home
  • Forums

Adding template output to an array

Development and Programming

Arun S.'s avatar
Arun S.
792 posts
17 years ago
Arun S.'s avatar Arun S.

Hey guys,

So, as I’ve mentioned before, I just started learning EE last week and am seriously loving it. The way I learn, as I think many of us do, is just by playing with things and then inevitbly messing something up (but that’s the fun part).

Anyway, so I’m picking up my second plugin. The first one was easy enough…this one is being more complicated.

Say you have some basic EE tags like this:

{exp:weblog:entries weblog="weblog"}
   {exp:myclass}{title}{/exp:myclass}
{/exp:weblog:entries}

What I’d love to be able to do is take all of the values that are output by the {title} tag and add them to a single array. Now, it seems that with each loop of the weblog:entries tag, it’s calling a new instance of “myclass” and therefore esentially resetting any arrays that are being created.

So my questions are: 1. Is it possible to add all the values of the {title} tag for the entire weblog:entries loop to an array? 2. If not, is there a way to fetch the paramaters of the weblog:entries tag to run dynamically generated SQL queries within a plugin? 3. Any alternative methods?

I’ve been staring at the docs for hours but can’t figure anything out.

       
Mr. Wilson's avatar
Mr. Wilson
131 posts
17 years ago
Mr. Wilson's avatar Mr. Wilson

Hi VB,

You can try something like this:

{exp:myclass}
  {exp:weblog:entries weblog="weblog" limit="5"}
   {myclass:variable}{title}{/myclass:variable}
  {/exp:weblog:entries}
{/exp:myclass}

After exp:weblog:entries runs, you’ll have something like:

{exp:myclass}
   {myclass:variable}Title 1{/myclass:variable}
   {myclass:variable}Title 2{/myclass:variable}
   {myclass:variable}Title 3{/myclass:variable}
   {myclass:variable}Title 4{/myclass:variable}
   {myclass:variable}Title 5{/myclass:variable}
{/exp:myclass}

You can then use a regular expression to fetch the values between the variable pairs and do with them what you will. Does that help get you started?

       
ExpressionEngineer's avatar
ExpressionEngineer
148 posts
17 years ago
ExpressionEngineer's avatar ExpressionEngineer

What Mr Wilson said, or you can use the $SESS->cache array.

       

Reply

Sign In To Reply

ExpressionEngine Home Features Pro Contact Version Support
Learn Docs University Forums
Resources Support Add-Ons Partners Blog
Privacy Terms Trademark Use License

Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.