One page template for multiple pages

Permalink
Not sure if this makes sense, but in my custom theme I'd like to use the same page template for multiple pages, each page of which would display images from different file sets. So, each of these pages are exactly the same format, just showing content from different sets.

My 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.

1 Attachment

 
jaulfh replied on at Permalink Reply
Just a bit of clarification to the OP, as maybe the subject line was not the best choice...

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.
ScottSandbakken replied on at Permalink Reply
ScottSandbakken
I am not sure I follow what you are asking, but I will try to help.

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();
jordanlev replied on at Permalink Reply
jordanlev
What you're describing is really just the same pattern as any other kind of page. You have a template (which is defined by your theme), and there is different content on each page. The way you should do this in Concrete5 is with blocks (just as if the content you wanted to add to the page was rich text or a youtube video).

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
jaulfh replied on at Permalink Reply
Hmm... wow, interesting. That's quite a tutorial! I'll go through it and see how I might apply some of those points.

Thanks very much!
jaulfh replied on at Permalink Reply
Solved:
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.