Page 1 of 2
Variable lists and what they point to.
Posted: Sun Feb 21, 2010 4:00 pm
by Izal
Variable lists and what they point to.
Where do I find the list of CMSMS variables that are accessible to the template engine and what data they hold that I can access?
I have a number of things I need to be able to grab from the CMSMS like I need to know that "Parent" menu I am user regardless of the sub menus under it or sub menu I am in. I also need to know the current page content URL, not just the current URL to the root page, like if I am in a news page for cheese and its page 6, the URL information of what page I am on needs to be passed to the SWF file I have installed on the page.
I need to reliably gather the current page content, I have to currently use the $url =urlencode( "http://".$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'] ); to reliably get the current URL, when I try
Code: Select all
global $gCms;
$hm =& $gCms->GetHierarchyManager();
$page_content_id = $gCms->variables['content_id'];
$curnode =& $hm->getNodeById($page_content_id);
$curcontent =& $curnode->GetContent();
$url = urlencode($curcontent->GetURL()); // url of current page
that I hacked out of an existing plugin, the output looks the same but when used in the template produces different results.
I am using {get_URL} as a UDT that spits out an encoded URL for a flash object, the URL requires the current page URL to function properly but I am not having much luck when I use the {current_page} plugin I made that is meant to do the same job.
What appears to happen is anything beyond the front page is not accessible to the flash item and the content defaults to the first page regardless of if I am on page 100 or page 10.
When I revert back to using the UDT and plain old PHP $_SERVER vars, it works on any page as its meant to work.
So can someone please assist with information on what variables I have access to and how I access that information.
Re: Variable lists and what they point to.
Posted: Mon Feb 22, 2010 12:26 pm
by Izal
Yes? No? Anyone?
Where do I get this information from? What is it labeled up as?
Re: Variable lists and what they point to.
Posted: Tue Feb 23, 2010 6:46 pm
by Izal
I forgot to mention that I did the "get template vars" thing and that tells me nothing useful.
So I would appreciate information on how I extract this information I need without having to invest in a crystal ball, tarrot readings and voodoo.
Re: Variable lists and what they point to.
Posted: Wed Feb 24, 2010 1:40 am
by kendo451
I was having no luck with it either, even after sacrificing several chickens. But then I hired a priest named Calguy and it goes better after that.
Re: Variable lists and what they point to.
Posted: Wed Feb 24, 2010 9:23 am
by Izal
Well if its money, you got more chance of talking a walk on the moon than me paying out money I haven't got. Living on welfare ain't easy.
Re: Variable lists and what they point to.
Posted: Wed Feb 24, 2010 5:03 pm
by kendo451
If you want the page URL in a template, install CGSimpleSmarty. It has lots of useful variables, including parent and sibling pages, content, urls, etc.
In a UDT I couldn't say.
Re: Variable lists and what they point to.
Posted: Mon Mar 08, 2010 11:07 am
by Izal
A UDT is out the question considering this is in a plugin I am writing and I can not for the life of me see how cal guys offering is going to help me in the completion of a plugin written in PHP that needs to draw its information from a PHP based system var that the CMS uses.
I do not see what is so hard about the devs just pointing me to the information I need or are the developers too involved with themselves to offer up some technical advice? A bit of hypocrisy going on here, they won't help noobs but as soon as you ask a tech question, you get blanked.
If anyone knows the answer I would appreciate the heads up.
Re: Variable lists and what they point to.
Posted: Mon Mar 08, 2010 4:35 pm
by kendo451
Well, they do try to help, but get an accusatory cranky attitude and nobody will want to help you, I can guarantee that.
Re: Variable lists and what they point to.
Posted: Mon Mar 08, 2010 5:02 pm
by jmcgin51
kendo451 wrote:
Well, they do try to help, but get an accusatory cranky attitude and nobody will want to help you, I can guarantee that.
I agree. Were I a developer reading your statement, Izal, offering assistance would be pretty much the last thing on my mind.
In the interest of rising above, I'll assume you must have been having a bad day, and point you to this article which you may or may not have already read:
http://calguy1000.com/Blogs/12/60/basic ... kills.html
Re: Variable lists and what they point to.
Posted: Mon Mar 08, 2010 5:52 pm
by kendo451
One other suggestion, about how to analyze an object to figure out which variable you need:
If you use print_r, don't forget the @
{$some_variable|@print_r}
alternatively var_dump works well too.
{$some_variable|@var_dump}
Re: Variable lists and what they point to.
Posted: Thu Mar 11, 2010 1:03 pm
by Peciura
To inspect CMSms variables in custom php code call smarty method "get_template_vars()"
http://www.smarty.net/manual/en/api.get ... e.vars.php
How to call smarty by it self ?
http://forum.cmsmadesimple.org/index.ph ... #msg185944
To extend kendo451's list of useful tags i suggest:
Built in plugin "dump"
and
General advice:
make sure variable "$gCms" is valid in your php code
Useful practice can be found on
http://wiki.cmsmadesimple.org/index.php/Developers
Re: Variable lists and what they point to.
Posted: Thu Mar 11, 2010 4:52 pm
by Izal
I had tried the get_template_vars and jumped through several hoops with various plugins suggest when ALL I want is to know what variable I call, use, access or property of that element to get the information I need.
$parent_menu = $gCms->? where ? is the property / class / OO reference to the information.
I am writing a plugin which needs to access this variable but where do I go for information, I have tried every suggestion to date and it is providing me with a big fat '0' in return information.
As for previous comments pulling me up for being "Cranky", rather its more like the devs are too childish to get over themselves to provide assistance which in all fairness, they will know what I am trying to gain access to but are obviously ignoring the request. Maybe if they grew up and took stock of the way they are running the show here, maybe, just maybe with a bit of an attitude change, things would really buzz around here but all it reminds me of is the Ubuntu forums.
Thanks to all those who have tried to help.
Ciao.
Re: Variable lists and what they point to.
Posted: Thu Mar 11, 2010 5:17 pm
by tyman00
The dev team is not childish. Calling them out like you are will definitely not get you any help. I may have an old-fashioned view but when I need help I don't bite the hand that feeds me.
I just deleted a huge post and I am going to sum it up here...
1.) Your original post was confusing to everyone. From those that have limited PHP experience to those that do it daily. You didn't get the answer you were looking for because no one fully understood your question.
2.) Your attitude and attacks turned people away. Even those that tried to help were smited.
3.) Your past precedes you. It's difficult to help someone that continually tears down the whole community and the team of people that donate their free time to provide a nice product like this. We aren't asking for everyone to agree with everything, but we are asking for a little tact along the way.
Re: Variable lists and what they point to.
Posted: Thu Mar 11, 2010 10:47 pm
by Peciura
This answer comes from the CMS Made Simple Documentation
Posted: Sat Mar 13, 2010 6:49 pm
by kendo451
Get the URL of a given page id
Code: Select all
$hm =& $gCms->GetHierarchyManager();
$curnode =& $hm->getNodeById($pageid);
$curcontent =& $curnode->GetContent();
echo $curcontent->GetURL();
Source:
http://wiki.cmsmadesimple.org/index.php/Creating_Modules