page_list templates - add a list of options to control layout from the block entry screen?

Permalink
Hi There,

I have 3 sets of page_list templates:
- Slider templates
- Templates that display content in blocks
- Templates that display content in stacks

Each of these then have a number of sub-templates that allow content to be displayed in different heights and widths.

The issue is that I have a total of 60 templates - most of these are simple .class change-outs to control layout.

Is there a way I can insert a text field or drop-down list into the block entry screen that would insert the classes? That way I could just have 4 templates instead of 60!

I'm guessing I need to create a variable that gets inserted into the template then somehow initialize a drop-down list so it appears in the block drop-down?

Not super proficient with PHP or Javascript at this point but am learning and can normally figure stuff out by trial and error - and help from you guys of course.

Any help or pointers in the right direction would be much appreciated.

Cheers

Ben

 
12345j replied on at Permalink Reply
12345j
you need to add a field to your block. call it class. in form.php (or edit+add.php) after copying to root/blocks/page_list
<label for="class"><?php echo t('Class');?></label>
<input type="text" name="class" value="<?php echo $class;?>"/>

then in db.xml after copying put in
<field name="class" type="C"/> just before the </table></schema>
then refresh the block type from add functionality, and in view.php where you want the class you entered: <?php echo $class;?>
cmscss replied on at Permalink Reply
Cheers mate, will have a look at this now.