vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vBulletin 4.x Add-ons (https://vborg.vbsupport.ru/forumdisplay.php?f=245)
-   -   Miscellaneous Hacks - [CMS] Parent Layout Overwrite (https://vborg.vbsupport.ru/showthread.php?t=247731)

civil78 07-31-2010 10:00 PM

[CMS] Parent Layout Overwrite
 
1 Attachment(s)
[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:

PHP Code:

$this->Load(); 


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
  1. 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".
  2. If you want to overwrite only the node under sections with specific layout (for example only articles) set "Parent Layout" and "Overwrite Layout"
  3. 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.

zero477 07-26-2012 08:20 PM

Hello,

It seems quite complicated ... I need to use different layouts for articles and sections ... I think it is a very obvious feature...

Can I see an example of the application??


All times are GMT. The time now is 02:53 PM.

Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.

X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.01100 seconds
  • Memory Usage 1,745KB
  • Queries Executed 10 (?)
More Information
Template Usage:
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (5)bbcode_php_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (2)printthreadbit
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • showthread
Included Files:
  • ./printthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/class_bbcode_alt.php
  • ./includes/class_bbcode.php
  • ./includes/functions_bigthree.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • printthread_start
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete