One page template for multiple pages
PermalinkMy thought was, in edit mode for a given page, have a "new Area('Set Name')" and enter the name of the image set (like "Scenery") to be displayed for that page. Then somehow get the name I enter to be used in "$fn = FileSet::getByName('Scenery')".
Any idea as to how I can get that name I entered from that editable area? I know I can get the area's array like:
$a = new Area('Set Name');
$area_array = $a->getAreaBlocksArray($c);
Dumping out the area_array contents (see attachment) I can see the string "Scenery" in a couple places, but I can't figure out how to extract it from that complicated array.
Or is there simply a better approach to what I'm attempting to do with templates and multiple pages?
Thanks for any suggestions.
I would use List Files by Set or Sortable Fancybox Gallery to display the images. Regardless of the block type, I would create the block programatically on the page.
Below is an example of an auto nav block. Just change the block type and add the correct options (basically anything in the block's db.xml file). This doesn't work with all blocks, but it is a good place to start.
$autoNavBlock = BlockType::getByHandle('autonav'); $autoNavBlock ->controller->displayPages = 'custom'; $autoNavBlock ->controller->displayPagesCID = 123; $autoNavBlock ->controller->displaySubPages = 'all'; $autoNavBlock ->controller->displaySubPageLevels = 'custom'; $autoNavBlock ->controller->divSubPageLevelsNum = '1'; $autoNavBlock ->controller->orderBy = 'display_asc'; $autoNavBlock ->render();
So what you should do is create a block that lets users choose a file set. Then users can add a new page of this page type, and then add the block to that page and choose the fileset via the block.
I wrote a tutorial on how to do this exact thing, and it includes links to code for this exact kind of block:
http://c5blog.jordanlev.com/blog/2011/12/build-a-slideshow-block/...
Good luck!
-Jordan
Thanks very much!
I figured out what I needed to get the file set name I had entered in edit mode. Actually very straight forward as follows:
$set_name = current($area_array)->getInstance()->getContent();
Thanks again to all of you who provided feedback.
Obviously it is typical to "apply" multiple pages to the same template, but the issue in this particular case is that the template currently has the file set name "hard coded", as in $fn = FileSet::getByName('Scenery'). So I want to be able to change the string 'Scenery' to other strings as well, depending upon the category of images (i.e. the page) I want to display.