Get parent alias

Pomoc po polsku dla CMS Made Simple
Post Reply
DiH
Forum Members
Forum Members
Posts: 14
Joined: Thu Nov 11, 2010 12:30 pm

Get parent alias

Post by DiH »

Witam. Zwracam się z pytaniem dlaczego poniższy kod, dodany jako UDT działa w wersji 1.8.2 CMSMS, a w wersji 1.9.2 już nie, wywalając błąd:
Call to a member function Alias() on a non-object in /home/jakassciezka/_cms/archives/lib/content.functions.php(975) : eval()'d code on line 22
Ewentualne rozwiązania mile widziane.

Kod:

Code: Select all

global $gCms;
global $smarty;

$manager =& $gCms->GetHierarchyManager();

$var = 'root_page_alias';
if( isset($params['assign']) && $params['assign'] != '' )
{
  $var = $params['assign'];
}
$result = "NO RESULT";

$rows = array();

$thisPage = $gCms->variables['content_id'];
$currentNode = &$manager->sureGetNodeById($thisPage);

$i = 0;
while( isset($currentNode))
{
    $currentContent =& $currentNode->getContent();
    $result = $currentContent->Alias();
    $currentNode =& $currentNode->getParentNode();
    $rows[$i++] = $result;
}
$result = $rows[2];

$smarty->assign($var,$result);
echo $result;
RonnyK
Support Guru
Support Guru
Posts: 4962
Joined: Wed Oct 25, 2006 8:29 pm
Location: Raalte, the Netherlands

Re: Get parent alias

Post by RonnyK »

To get parent alias, you could use CGSimpleSmarty. When installed, you can call,

Code: Select all

The parent page alias is {$cgsimple->get_parent_alias()}
Ronny
DiH
Forum Members
Forum Members
Posts: 14
Joined: Thu Nov 11, 2010 12:30 pm

Re: Get parent alias

Post by DiH »

Thanks, I'll try it out. But actually, getting parent alias isn't a problem for me. With the code I've used I was able to access whatever parent I wanted - whether it was only one level above in hierarchy, three, or four etc.
maranc
Forum Members
Forum Members
Posts: 249
Joined: Tue May 04, 2010 5:04 pm

Re: Get parent alias

Post by maranc »

Code: Select all

global $gCms;
- zmienna globalna która nie działa od wersji 1.9 - to przyczyna. W twoim UDT dodaj wiersz:

$gCms = cmsms(); albo po prostu zadeklaruj globalną zmienną cmsms().

Przy okazji uwaga dla wielu PL użytkowników CMSMS - znaczna część UDT które znjadziecie na forach EN nie będzie działała właśnie z tego powodu.
BTW - Ronny dobrze Ci doradził, aby użyć CGSimpleSmarty, poza opcją parent jest tam w parę innych użytecznych tagów.

Pozdr.
Marek A.
Post Reply

Return to “Polish - Polski”