[solved] help learning how to access any value of content object

General project discussion. NOT for help questions.
Post Reply
blackhawk
Power Poster
Power Poster
Posts: 280
Joined: Mon Oct 20, 2008 6:07 pm

[solved] help learning how to access any value of content object

Post by blackhawk »

Sup peeps,
I got awesome feedback from you guys on how to access the extra1 field with the content_obj, which works great with mPropertyTypes values!

Code: Select all

$getfield = $content_obj->GetPropertyValue('extra1');
But now that I look at the entire object, is there "a way" that I can learn how to access any array value of the object?  For example, I want to access the mName (which I assume is the title of the content page?).  So I did this...

Code: Select all

$content_obj = $smarty->get_template_vars('content_obj');
$getname = $content_obj->GetPropertyValue('mName');

print 'the title of the page is: '.$getname;


But it didn't work.  I'm willing to learn!

Thanks
Last edited by blackhawk on Tue Nov 16, 2010 5:28 pm, edited 1 time in total.
NaN

Re: help learning how to access any value of content object

Post by NaN »

Don't use the 'm-variables'.
They are private vars that are not accessible from 'outside' of the content-object context.
You cannot access them in CMSms 1.9 anymore.

Every content has some base properties (like title, alias, menutext ... the 'm-variables')
These base properties cannot be accessed using the GetPropertyValue() function.
The GetPropertyValue() function is only to get content type related property values.
(like contentblocks, extra fields ... stuff that only belongs to certain content types)

The base properties are defined in a ContentBase object that is extended by all other content types.
For almost each base property there is a public function that will return the value of that property.

Examples:

Title:
Wrong: $content_obj->mName
Right: $content_obj->Name()

Alias:
Wrong: $content_obj->mAlias
Right: $content_obj->Alias()

and so on.

Here is a full documentation of the contentbase object:
http://www.cmsmadesimple.org/apidoc/CMS ... tBase.html
blackhawk
Power Poster
Power Poster
Posts: 280
Joined: Mon Oct 20, 2008 6:07 pm

Re: help learning how to access any value of content object

Post by blackhawk »

sweet!!! thanks NaN
Post Reply

Return to “General Discussion”