Page 1 of 1

[SOLVED] Global content blocks not working on subpages

Posted: Tue Aug 17, 2010 10:27 am
by Rednes
G'day fellow developers,

Im working on a site that uses smoothscroll to scroll to the next page, instead of clicking a link and reloading the page. The content of all the pages is allready there, you only need to scroll to it. example of such a site: http://www.pelicanhotel.com/

I created a UDT to display all the subpages that are under a certain parent in the pages section of the admin section of cmsms. This way, the admin can easily edit the content without having to much knowledge of html/css.

Only thing now is that I can't use globalcontent blocks on those subpages anymore. GCB's work on the parent page "Home", but not on the subpages. My guess it has something to do with the UDT i'm using. see below

Code: Select all

global $gCms;
$manager =& $gCms->GetHierarchyManager();
$thisPage = $gCms->variables['page_name'];
$currentNode = &$manager->sureGetNodeByAlias($thisPage);
$contentops =& $gCms->GetContentOperations();

$nodes = $currentNode->getChildren();

if ($currentNode->hasChildren()) {
 
 foreach ($nodes as $node) {

     $content= $node->getContent();
    
$contentx = $contentops->LoadContentFromAlias($content->Alias());    
print_r($contentx->mProperties->mPropertyValues[content_en]);
 

 }
I call this UDT in my main template and am not using the {content} tag for it.
So, GCB's work on page "Home", but not on the subpages.
And smarty tags in general won't work on those subpages.
A tag is being ouputted as text and not initializing smarty.


The structure of my pages is like this:

+ Home
   - subpage1
   - subpage2
   - subpage3


Any thoughts?

Red.

edit: I tried calling above UDT {list_children} on the home page, so that the content is being displayed threw {content}. Still can't use smarty tags on the subpages though.




CMS Made Simple Version: 1.8.1

Installed Modules:

   * CMSMailer: 2.0
   * FileManager: 1.0.2
   * MenuManager: 1.6.5
   * ModuleManager: 1.4
   * News: 2.10.6
   * nuSOAP: 1.0.1
   * Printing: 1.1.0
   * Search: 1.6.5
   * ThemeManager: 1.1.1
   * TinyMCE: 2.7.2
   * FormBuilder: 0.6.2

Current PHP Version: 5.2.6

PHP Configuration:

   * Maximum Post Size: 10M
   * Maximum Upload Size: 10M
   * PHP Memory Limit: 32M
   * PHP Safe Mode: Off
   * Maximum Execution Time: 60 seconds
   * Session Save Path: /var/lib/php/php5sessions

MySQL Server Version: 5.0.27

Server Software: Apache/2.0.54 (Fedora)
Server API: CGI-FCGI
Server OS: Linux v 2.6.18-028stab060.8 on i686 architecture

Directory Permissions:

   * tmp/cache - 0755
   * tmp/templates_c - 0755
   * uploads - 0755
   * modules - 0755

Browser: Mozilla/5.0 (Windows; U; Windows NT 6.1; nl; rv:1.9.2.8.) Gecko/20100722 Firefox/3.6.8

Re: Global content blocks not working on subpages

Posted: Tue Aug 17, 2010 2:54 pm
by Rednes
vilkis is tha man! Not only for helping out and kickstarting me in the right direction but also for spending time on this.

The thing was with the original UDT, that the "content" wasnt being compiled by smarty.

See below for the edited UDT (with smarty compiling):

Code: Select all

global $gCms;
$manager =& $gCms->GetHierarchyManager();
$thisPage = $gCms->variables['page_name'];
$currentNode = &$manager->sureGetNodeByAlias($thisPage);
$contentops =& $gCms->GetContentOperations();
$nodes = $currentNode->getChildren();
if ($currentNode->hasChildren()) { 
 foreach ($nodes as $node) {
     $content= $node->getContent();    
     $contentx = $contentops->LoadContentFromAlias($content->Alias());   
     $onecontent = $contentx->mProperties->mPropertyValues[content_en];
     $smarty->_compile_source('temporary template', $onecontent , $compiled);
       @ob_start();
       $smarty->_eval('?>' . $compiled);
       $contentx = @ob_get_contents();
       @ob_end_clean();         
       echo $contentx;
 }
}

Thank you (again) vilkis!

Re: [SOLVED] Global content blocks not working on subpages

Posted: Thu Mar 03, 2011 3:43 pm
by [MaGuS]
Hi!

Tried to follow your code but there is empty space only :( Code
enumerated through the menu items but no processed pages shown...