[SOLVED] get page alias in UDT for use in admin page templat

Have a question or a suggestion about a 3rd party addon module or plugin?
Let us know here.
Locked
applejack
Power Poster
Power Poster
Posts: 1014
Joined: Fri Mar 30, 2007 2:28 am

[SOLVED] get page alias in UDT for use in admin page templat

Post by applejack »

I need to be able to get the page alias in a UDT which is used in admin in a page template. This to use the dropdown_from_udt in ECB module for which I am trying to pull data from certain content blocks from the same page which I can do if the alias is in the UDT. It isn't possible to pass a Smarty param to the UDT. I just don't know the api syntax for doing this.

I tried using $content_obj->Alias() but it doesn't work.

Code: Select all

$result = false;
$gCms = cmsms();
$contentops = $gCms->GetContentOperations();
$content_obj = $contentops->getContentObject();

$result = Array();
    
// $alias = "events-test"; THIS WORKS
$alias = $content_obj->Alias();

if( $alias != '' ) {
    $content = $contentops->LoadContentFromAlias($alias);
    if(is_object($content)) {
        for ($i=1;$i<=2;$i++) {
            $block = 'speaker_name_' . $i;
            $result[$content->GetPropertyValue($block)] = $content->GetPropertyValue($block);
        }    
      }    
    }
return $result;
Last edited by applejack on Thu Jan 29, 2015 10:49 am, edited 1 time in total.
chandra

Re: How to get page alias in UDT for use in admin page templ

Post by chandra »

The answer is simple - $content_obj does not exist in admin ;).
applejack
Power Poster
Power Poster
Posts: 1014
Joined: Fri Mar 30, 2007 2:28 am

Re: How to get page alias in UDT for use in admin page templ

Post by applejack »

So in that case how to get the page alias or content id ?
User avatar
rotezecke
Power Poster
Power Poster
Posts: 411
Joined: Fri Apr 18, 2008 9:34 pm

Re: How to get page alias in UDT for use in admin page templ

Post by rotezecke »

does this work?

Code: Select all

$hm = cmsms()->GetHierarchyManager();
$node = $hm->getId();
applejack
Power Poster
Power Poster
Posts: 1014
Joined: Fri Mar 30, 2007 2:28 am

Re: How to get page alias in UDT for use in admin page templ

Post by applejack »

Nope afraid not. Gives a blank screen when trying to edit the page.
User avatar
velden
Dev Team Member
Dev Team Member
Posts: 3497
Joined: Mon Nov 28, 2011 9:29 am

Re: [SOLVED] get page alias in UDT for use in admin page tem

Post by velden »

Would this work:

Code: Select all

$_GET['content_id'];
applejack
Power Poster
Power Poster
Posts: 1014
Joined: Fri Mar 30, 2007 2:28 am

Re: [SOLVED] get page alias in UDT for use in admin page tem

Post by applejack »

I solved this using GET which I tried before but had a syntax error, Doh!!

It now uses the content id not the alias.

This very useful as it enables you to cross reference content within a page. E.G. This is for a page for conference programme where they have a number of speakers which need to show their details and assign a number of speakers to different time slots which this allows me to do.

Code: Select all

$result = false;
$gCms = cmsms();
$contentops = $gCms->GetContentOperations();
$content_obj = $contentops->getContentObject();

$result = Array();
$page_id = htmlspecialchars($_GET['content_id']);

if($page_id != '') {
    $content = $contentops->LoadContentFromID($page_id);
    if(is_object($content)) {
        for ($i=1;$i<=2;$i++) {
            $block = 'speaker_name_' . $i;
            $result[$content->GetPropertyValue($block)] = $content->GetPropertyValue($block);
        }    
      }    
    }
return $result;
P.S. Thanks Velden I was in the middle of posting this when you replied.
Locked

Return to “Modules/Add-Ons”