Concatenation of DEFINEd variables?

All style (template, theme and imageset) related questions for the new release; advice, feedback here please.
Post Reply
ShanwickOceanic
Registered User
Posts: 3
Joined: Thu Feb 05, 2009 10:25 pm

Concatenation of DEFINEd variables?

Post by ShanwickOceanic »

I have a template for a glass bar, which can take some content on the left- and right-hand sides. I call it like this:

Code: Select all

<!-- DEFINE $LEFTHANDCONTENT = 'html for lhs' -->
<!-- DEFINE $RIGHTHANDCONTENT = 'html for rhs' -->
<!-- INCLUDE glassbar.html -->
Among other things, I'm using this glass bar as the header for my posts, and this is where the fun starts. $RIGHTHANDCONTENT is going to be all the post action icons (Edit, Delete, Quote, etc.) - and that will have to be built up using the logic that's already in the prosilver template, depending on the current user's permissions. In pseudocode:

Code: Select all

$RIGHTHANDCONTENT = 'html for any common stuff';
if(can quote) {
  $RIGHTHANDCONTENT = $RIGHTHANDCONTENT + 'html for quote button';
}
if(can edit) {
  $RIGHTHANDCONTENT = $RIGHTHANDCONTENT + 'html for edit button';
}
if(can delete) {
  $RIGHTHANDCONTENT = $RIGHTHANDCONTENT + 'html for delete button';
}
How do I do this using DEFINE? Without this ability, it seems I have two alternatives:

i) DEFINE far more variables, say $RIGHTHANDCONTENT1 through $RIGHTHANDCONTENT10, and modify the template to concatenate them, empty or not,

or

ii) re-implement all this perfectly good template logic in PHP and template->assign_var a single string.

Neither of these strikes me as being particularly nice. My background is JSP, where I'm used to doing <c:set var ="myVar">${myVar}new stuff on the end</c:set> - am I expecting too much of the templating system here?

ShanwickOceanic
Registered User
Posts: 3
Joined: Thu Feb 05, 2009 10:25 pm

Re: Concatenation of DEFINEd variables?

Post by ShanwickOceanic »

Even a confirmation that I can't do this would be helpful.

Post Reply