Ok, here I am, using sections and sub-sections, and sub-sub-sections to navigate in my site.
My publication has 5 top sections, and they all share the same layout, except for one div, changing color for each section.
I thought using the current section name in my layout to give the right css style to that div. But I don't know how to get the top section's nickname when I'm in a sub-sub-section. Any idea ?
Another thing :
in a view, matching a section of course, can I access to a content like :
<?php $section['doc-nickname']['url'] ?> or something close to that, instead of using <?php $section['childContents'][1]['url'] ?> which is not very informative about what is not really explicit about the content when you read the code ?
if (!empty($this->viewVars['section'])) {
$this->viewVars['section']['childContents'] = Set::combine($this->viewVars['section']['childContents'], '{n}.nickname', '{n}');
}
Thanks guys for the help, I've made a lot of progress so far.
I have a section, nicknamed home_page
I want to write an action where I analyze the content of the section, and pass just selected data to the view. How do I do that ?
// here you can handle the section array you find in $this->viewVars['section']. In view you refer to it with $section var
And how do I pass a variable to the layout ? Like the top section nickname ?
when I have an action, the $section variable isn't anymore available from the layout.ctp. I don't get that.
Thanks
Il giorno mercoledì 25 aprile 2012 15:30:09 UTC+2, tiofred ha scritto:when I have an action, the $section variable isn't anymore available from the layout.ctp. I don't get that.
Right, if you use a specific action of your controller it skips the default loading of section data, so $section var isn't avaiable in view.
You should use the callback beditaBeforeRender() instead of beditaBeforeFilter(). In fact before filter is called before of the action method so you haven't any section data there.
<img src="{$beEmbedMedia->object($media, ['URLonly' => true, 'width' => 200, 'height' => 200])}" alt="{$media.title}" />
Another example (from bedita/examples/wp.example.com):
{assign_associative var="options" mode="fill" width=100 height=100 modeparam="000000" upscale=true}
{assign_associative var="htmlAttr" style="float: left; width: 100px; height: 100px; margin: 10px 20px 10px 0"}
<a rel="gallery" title="{$media.title}" href="{$beEmbedMedia->object($media, $options)}" {$beEmbedMedia->object($media, $options, $htmlAttr)}</a>
You can find more examples here: http://docs.bedita.com/frontends/embedding-media-object.
A simple example:
<img src="{$beEmbedMedia->object($media, ['URLonly' => true, 'width' => 200, 'height' => 200])}" alt="{$media.title}" />