$data
$data : array
Data to pass to the style
This class is responsible for all style management. It is instantiated by the MidCOM framework and accessible through the midcom::get()->style object.
The method show($style)
returns the style element $style for the current
component:
It checks whether a style path is defined for the current component.
(The default fallback is always the default style, e.g. if $style is not in the user defined style path)
To enable cross-style referencing and provide the opportunity to access any style element, "show" can be called with a full qualified style path (like "/mystyle/element1", while the current page's style may be set to "/yourstyle").
Note: To make sure sub-styles and elements included in styles are handled correctly, use:
<?php midcom_show_style ("elementname"); ?>
Style Inheritance
The basic path the styleloader follows to find a style element is:
Regarding nr. 4: It is possible to add extra file styles if so is needed for example by a portal component. This is done either using the append/prepend component_style functions or by setting it to another directory by calling (append|prepend)_styledir directly.
NB: You cannot change this in another style element or in a _show() function in a component.
$_topic : \midcom_db_topic
Current topic
get_style_id_from_path(string $path, integer $rootstyle) : integer
Returns the id of the style described by $path.
Note: $path already includes the element name, so $path looks like "/rootstyle/style/style/element".
string | $path | The path to retrieve |
integer | $rootstyle | ??? |
ID of the matching style or false
render(string $preparsed, string $path, array $data = array())
Renders the style element with current request data
string | $preparsed | The element's content as executable code |
string | $path | the element's name |
array | $data | Request date, if you don't want to use the global data |
show_midcom(string $path) : boolean
Looks for a midcom core style element matching $path and displays/evaluates it.
This offers a bit reduced functionality and will only look in the DB root style, the theme directory and midcom's style directory, because it has to work even when midcom is not yet fully initialized
string | $path | The style element to show. |
True on success, false otherwise.
_get_element_in_styletree(integer $id, string $name) : string
Returns a style element that matches $name and is in style $id.
It also returns an element if it is not in the given style, but in one of its parent styles.
integer | $id | The style id to search in. |
string | $name | The element to locate. |
Value of the found element, or false on failure.
_get_component_style(\midcom_db_topic $topic) : integer
Gets the component style.
\midcom_db_topic | $topic | Current topic |
Database ID if the style to use in current view or false
_merge_styledirs(string $component_style)
Merge the prepend and append styles with the componentstyle. This happens when the enter_context function is called.
You cannot change the style call stack after that (unless you call enter_context again of course).
string | $component_style |