[CMS] Parent Layout Overwrite
Created by civil78
The problem :
Sometimes a vbulletin web developer wants to have different layout in section pages and article pages. In vbulletin there is no setting for that and the article pages uses the parent (section that belongs) layout.
How it works :
This product overwrites the layout of specific nodes by replacing the parent layout globally or for specific sections.
Installation
- Import product product-parrent_layout_overwrite
- Edit File @root@\packages\vbcms\item\content.php
- Find function getLayoutId() and inside function add this
Edit 01
AFTER:
ADD :
PHP Code:
// PLO - EDIT START
$plo_originallayoutid = $this->layoutid;
// PLO - EDIT END
Edit 02
BEFORE:
PHP Code:
return $this->layoutid;
ADD :
PHP Code:
// PLO - EDIT START
global $vbulletin;
if (($vbulletin->options['plo_active']) && ($vbulletin->options['plo_overwrite_lid']) && (!$plo_originallayoutid)) {
if ($vbulletin->options['plo_parent_lid']) {
if ($this->layoutid == $vbulletin->options['plo_parent_lid']) {
$this->layoutid = $vbulletin->options['plo_overwrite_lid'];
}
} else {
$this->layoutid = $vbulletin->options['plo_overwrite_lid'];
}
}
// PLO - EDIT END
The final code looks like this (on 4.0.5)
PHP Code:
public function getLayoutId()
{
$this->Load();
// PLO - EDIT START
$plo_originallayoutid = $this->layoutid;
// PLO - EDIT END
if (!$this->layoutid)
{
//If our parent doesn't have the style defined, we need to go up the chain until we find one.
if (! ($record = vB::$vbulletin->db->query_first("SELECT layoutid FROM " . TABLE_PREFIX . "cms_node AS node
WHERE (" .
$this->nodeleft . " BETWEEN node.nodeleft AND node.noderight) AND layoutid > 0 ORDER BY nodeleft DESC LIMIT 1" ))
or
(! intval($record['layoutid'])))
{
//There appears to be nothing defined. All we can do is pull the first record.
$record = vB::$vbulletin->db->query_first("SELECT layoutid FROM " . TABLE_PREFIX . "cms_layout LIMIT 1" );
}
$this->layoutid = $record['layoutid'];
}
// PLO - EDIT START
global $vbulletin;
if (($vbulletin->options['plo_active']) && ($vbulletin->options['plo_overwrite_lid']) && (!$plo_originallayoutid)) {
if ($vbulletin->options['plo_parent_lid']) {
if ($this->layoutid == $vbulletin->options['plo_parent_lid']) {
$this->layoutid = $vbulletin->options['plo_overwrite_lid'];
}
} else {
$this->layoutid = $vbulletin->options['plo_overwrite_lid'];
}
}
// PLO - EDIT END
return $this->layoutid;
}
- Go to Vbulletin settings and on setting group "Parent Layout Overwrite" change the settings.
Also if you have 4.0.5 version (but only that) you can just upload the files inside "upload (only for vbulletin 405)" folder of the zip file.
Remember if you upgrade the vbulletin to new version you have to make these edits again.
Instructions
Go to vBulletin Options --> Parent Layout Overwrite
First activate the product
- If you want to overwrite all the empty node layouts (that means all the nodes even 'PHP Direct Evaluation' and 'Static Page' but not the sections pages) leave empty the "Parent Layout" and set the "Overwrite Layout".
- If you want to overwrite only the node under sections with specific layout (for example only articles) set "Parent Layout" and "Overwrite Layout"
- If you leave empty both the "Parent Layout" and "Overwrite Layout", nothing will change.
Difficulty: Normal - Need to be little familiar with php
Time to install: 3-4 minutes.
History
1.0 - 01/08/2010 - Initial release.
P.S. This mod tested on 4.0.5 version but maybe run and on older versions.