Where/How can I store a Tempcode array?

Post

Posted
Rating:
#4228 (In Topic #856)
Joe
Avatar
Standard member
Joe is in the usergroup ‘Honoured member’
If I want to LOOP through a list of arrays, where do I store/write them? Do I nest them inside some other Tempcode like $SET or something?

I could write them out inline, like so:

Code

{+START,LOOP,a\,b\,c}...{+END}

But I'm not sure I want to go about it that way. If I could store them in a file or separate template on the server, that'd be cool, otherwise I suppose I could write them inline, I just think it looks messy.

Oh yes, and I'm new with arrays. Trying to broaden my Tempcode knowledge :thumbs:  :thumbs:  :lol:
Online now: No Back to the top

Post

Posted
Rating:
#4230
Avatar
Site director
Chris Graham is in the usergroup ‘Administrators’
You could put them into a variable using $SET, and include that using the INCLUDE directive. That would let you include them into multiple pages.


Become a fan of Composr on Facebook or add me as a friend. Add me on on Mastodon. Follow me on Minds (where I am most active). Support me on Patreon

Was I helpful?
  • If not, please let us know how we can do better (please try and propose any bigger ideas in such a way that they are fundable and scalable).
  • If so, please let others know about Composr whenever you see the opportunity or support me on Patreon.
  • If my reply is too Vulcan or expressed too much in business-strategy terms, and not particularly personal, I apologise. As a company & project maintainer, time is very limited to me, so usually when I write a reply I try and make it generic advice to all readers. I'm also naturally a joined-up thinker, so I always express my thoughts in combined business and technical terms. I recognise not everyone likes that, don't let my Vulcan-thinking stop you enjoying Composr on fun personal projects.
  • If my response can inspire a community tutorial, that's a great way of giving back to the project as a user.
Online now: No Back to the top

Post

Posted
Rating:
#4231
Joe
Avatar
Standard member
Joe is in the usergroup ‘Honoured member’
So, the syntax would be like this?

Code

{$SET,EXAMPLE,'EXAMPLE'=>array('a','b','c')}
Online now: No Back to the top

Post

Posted
Rating:
#4232
Avatar
Site director
Chris Graham is in the usergroup ‘Administrators’
No, that looks like PHP code, and Tempcode isn't based around PHP syntax at all. It would actually be much like what you had in your original code, just encapsulated as a parameter to SET rather than LOOP.

{$SET,EXAMPLE,a\,b\,c}


Become a fan of Composr on Facebook or add me as a friend. Add me on on Mastodon. Follow me on Minds (where I am most active). Support me on Patreon

Was I helpful?
  • If not, please let us know how we can do better (please try and propose any bigger ideas in such a way that they are fundable and scalable).
  • If so, please let others know about Composr whenever you see the opportunity or support me on Patreon.
  • If my reply is too Vulcan or expressed too much in business-strategy terms, and not particularly personal, I apologise. As a company & project maintainer, time is very limited to me, so usually when I write a reply I try and make it generic advice to all readers. I'm also naturally a joined-up thinker, so I always express my thoughts in combined business and technical terms. I recognise not everyone likes that, don't let my Vulcan-thinking stop you enjoying Composr on fun personal projects.
  • If my response can inspire a community tutorial, that's a great way of giving back to the project as a user.
Online now: No Back to the top
1 guest and 0 members have just viewed this.

Statistics

Forum statistics:
  • 2,052 topics, 7,195 posts, 10,827 members
  • Our newest member is LowfareMart
Back to Top