areas from another theme page
Permalink
currently tinkering with jqmobile in c5 where the jqmobile uses multiple pages on one default.php.
I have two themes which i switch between depending if mobile or desktop device used. The mobile theme displays the data input from the desktop theme using the following in the (mobile) default.php
<div data-role="page" id="page2">
<div data-role="header">
<h1>Page Two</h1>
</div>
<div data-role="content">
<?php
$as = new Area('Main');
$as->display($c);
?>
</div>
<div data-role="footer">
<h4>Page Footer</h4>
</div>
</div>
This only seems to display data placed into the Home page of the desktop theme and not any other pages created using the same template. Is there a way in the php code above I can select the data from a page other than Home.
thanks
I have two themes which i switch between depending if mobile or desktop device used. The mobile theme displays the data input from the desktop theme using the following in the (mobile) default.php
<div data-role="page" id="page2">
<div data-role="header">
<h1>Page Two</h1>
</div>
<div data-role="content">
<?php
$as = new Area('Main');
$as->display($c);
?>
</div>
<div data-role="footer">
<h4>Page Footer</h4>
</div>
</div>
This only seems to display data placed into the Home page of the desktop theme and not any other pages created using the same template. Is there a way in the php code above I can select the data from a page other than Home.
thanks
thanks , I tried both ways using ByID and ByPath but does not return anything
<?php
//$objPage = Page::getByID(Merchant);
$objPage = Page::getByPath('../c5c_theme/merchant.php');
$a = new Area('Merch1');
$a->display($objPage);
?>
I think I have the correct page ID as use the following on the page where i need the data from and this returns Merchant.
<?php
$page = Page::getCurrentPage();
echo $page->getCollectionName();
?>
Not sure what i am doing wrong
<?php
//$objPage = Page::getByID(Merchant);
$objPage = Page::getByPath('../c5c_theme/merchant.php');
$a = new Area('Merch1');
$a->display($objPage);
?>
I think I have the correct page ID as use the following on the page where i need the data from and this returns Merchant.
<?php
$page = Page::getCurrentPage();
echo $page->getCollectionName();
?>
Not sure what i am doing wrong
Your id is wrong (you're just passing in the word Merchant -- it needs to br a number). And your path is wrong too - it is not a file path but instead it is the "C5 path", which is basically everything after the domain name in the URL. So if the page URL ishttp://example.com/about/company... , then the path is "/about/company".
Glad you got it working, however, if you're going to mark your answer as the best you should probably update it with the revised code so as not to confuse future readers.
sorry still learning, it works now so thanks to both of you for the help on this.
There is, however, an add-on in the marketplace that will do all this for you so you don't have to touch the code itself (and is a better method for the more complex blocks). I'll track it down unless someone posts a link for me...
Edit: Found it -http://www.concrete5.org/marketplace/addons/global-areas/...