SOLVED: Pulling array of variables into separate content page

For questions and problems with the CMS core. This board is NOT for any 3rd party modules, addons, PHP scripts or anything NOT distributed with the CMS made simple package itself.
Post Reply
appleyard
Forum Members
Forum Members
Posts: 27
Joined: Wed Dec 30, 2009 2:54 pm

SOLVED: Pulling array of variables into separate content page

Post by appleyard »

Most of the sites I've been building with CMSMS so far have been pretty simple/straightforward, but I had a question about using the "Extra Page Attribute" fields for something in a project I'm working on...

Basically, this site will have a group of pages in which each page represents a house for sale. There will be a small spot for an integrated Google Maps box, which I could do manually for each house with no problem. However, I'd also like to have a separate page with a larger map that plots out each house automatically using the coordinates from each individual page.

I was wondering if it's possible to use an "Extra Page Attribute" field for the Google Maps coordinates, and to pull that string from each house page to generate the larger map. Specifically I want to call all child pages from a particular parent (e.g. a section called "Houses"), check if they have a value for Extra Page Attribute 1, and plug that into {foreach} to plot the map coordinates with a link to the corresponding page. Does that make sense?

Any help you guys can provide would be appreciated! Thanks!

EDIT: Subject changed to reflect using content block variables instead of Extra Page Attribute fields.
Last edited by appleyard on Tue Apr 20, 2010 7:48 pm, edited 1 time in total.
sgtstevil
Forum Members
Forum Members
Posts: 22
Joined: Wed Jan 13, 2010 3:26 pm

Re: Pulling array of "Extra Page Attribute" fields into separate content page

Post by sgtstevil »

Try downloading CGSimpleSmarty from the Module Manager, and adding content-blocks to your page like so:
{content block="Google Maps Coordinates" assign="coords" wysiwyg="false" oneline="true"} and call it with {$coords} where you want to place it in the page.

Then go to Menu Manager. CGSimpleSmarty will let you access different content-blocks like so:

Code: Select all

<ul>
{foreach from=$nodelist item=node}
{$cgsimple->get_page_content($node->alias,'Google_Maps_Coordinates,'coords')}
<li>{$coords}</li>
{/foreach}
</ul>
Keep in mind that you have to call the variables as you originally assigned them on the page (Google Maps Coordinates in this case, NOT coords), but with spaces replaced by underscores.

This would create an unsorted list, change to however the params would be passed to Google Maps, or to a JavaScript or whatever :).

Then call this menu-template like {menu template="Coordinate List" start="2.1" number_of_levels="1" start_level="3"}, and presto!
appleyard
Forum Members
Forum Members
Posts: 27
Joined: Wed Dec 30, 2009 2:54 pm

Re: Pulling array of "Extra Page Attribute" fields into separate content page

Post by appleyard »

This looks like it will work perfectly. I was confusing the Extra Page Attribute fields for the functionality that Content Blocks provide. (I was heretofore unaware of how to use them!) I'll let you know (and add 'SOLVED' to the subject) if/when I get the thing working. Thanks very much, sgtstevil!
appleyard
Forum Members
Forum Members
Posts: 27
Joined: Wed Dec 30, 2009 2:54 pm

Re: Pulling array of "Extra Page Attribute" fields into separate content page

Post by appleyard »

Consider this SOLVED. Thanks again, sgtstevil! I did a few things differently from your suggestion, but the concept was the same. Content blocks + CGSimpleSmarty = extremely versatile tool!
sgtstevil
Forum Members
Forum Members
Posts: 22
Joined: Wed Jan 13, 2010 3:26 pm

Re: SOLVED: Pulling array of variables into separate content page

Post by sgtstevil »

most welcome! :)
Post Reply

Return to “CMSMS Core”