====== geoView ====== This class is responsible for most of the "grunt" work of displaying the page. It is more of a "utility" class however, so it needs to be set up to do what is needed, that part is usually done by the **display_page** method inside the **geoSite** class. If you "set up" this class properly, you could totally bypass the display_page function to display the page however you want. ===== Get an Instance ===== This class, like most of the main "system" level classes, uses a [[http://www.google.com/search?q=singleton+method|Singleton method]] to ensure that only 1 instance of the class exists at any one time. To get the view class, in your addon you would do something like this: $view = geoView::getInstance(); When you do it properly like above, that ensures when you interact with the geoView class, to change a system template variable for example, that you will be interacting with the same class that is used to display the page later in the page load. ===== Manipulating System Template Variables ===== For this explanation, lets say in your addon, you wanted to alter the data used to display the "mainbody" template on a certain page. It happens that the "best place" to do that, would be in the [[developers:addons:core_events|Core Event]] **notify_display_page**. See the Example addon documentation for more information on that core event. We won't go over how to use core events here, instead we'll be skipping straight to how to manipulate the geoView template variables. First, wherever in your addon you are manipulating the geoView variables, you would first get an instance of the geoView class: $view = geoView::getInstance(); Now, you want to manipulate one of the variables that will be used. First, you need to figure out what the exact name of that variable would be and how to access it, so for //exploration purposes//, do the following: echo "DEBUG: geoView Variables:
".htmlspecialchars(print_r($view,1))."


";
Now go look at the page in a browser. The above should give us something like: DEBUG: geoView Variables: geoView Object ( [_viewVars:protected] => Array ( [vars] => Array ( [category_id] => 12 [site_url] => index.php [browsetype] => Array ( [param] => 0 [category] => 0 [classified] => 0 [auction] => 0 ) [browsing_options] => 1 [category_name] => Announcements [category_cache] =>
Current Category: Main > Announcements
[pc] => Array ( [classifieds] => 1 [auctions] => 1 ) ) [geo_inc_files] => Array ( [body_html] => browse_ads.tpl [body_html_system] => browsing ) [body_vars] => Array ( [category_id] => 12 [site_url] => index.php [browsetype] => Array ( [param] => 0 [category] => 0 [classified] => 0 [auction] => 0 ) [browsing_options] => 1 [category_name] => Announcements [category_cache] =>
Current Category: Main > Announcements
[pc] => Array ( [classifieds] => 1 [auctions] => 1 ) ) ) [_modules:protected] => ..........
The //[_viewVars:protected]// variable print-out is what we are interested in here. See that there is a variable in the above example that would be something like: $view->_viewVars['vars']['category_id'] We can't actually access it like that, as the $_viewVars is a //protected// class variable. Instead, to access the above, you would use: $view->vars['category_id'] Here is another more generic example to make it clear how to access different variables: From the print-out, a variable might be: $view->_viewVars['var1']['sub_var1']['sub_sub_var5']; Access the above like so: $view->var1['sub_var1']['sub_sub_var5'];