Members: 16,996
Threads: 38,845
Posts: 159,389
Online: 13

Newest Member: Kl_broka@rediffmail.com


Odoo.tv - Outdoor Television


Sedo - Domains kaufen und verkaufen das Projekt mambers.com steht zum Verkauf Besucherstatistiken von mambers.com etracker® Web-Controlling statt Logfile-Analyse

Go Back   Mambers.com > Templates > Template Discussions

Reply
 
LinkBack Thread Tools Display Modes
Old 18.04.2004, 16:58   #21 (permalink)
Baby Mamber
 
Glitchy's Avatar
 
Join Date: Apr 2004
Location: Toronto
Posts: 16
Glitchy is on a distinguished road
Post Re: Different frontpage template

The best way to do it, (so that you don't change any of the core, is to split your template/name/index.php into three files.

index.php
PHP Code:
  if (($option=="com_frontpage") or (substr($PHP_SELF, -8))=="index.php") {
   include (
"template1.php");
 } else {
   include (
"template2.php);
 } 
template1.php = frontpage templates

template2.php = template for the rest of the site

----

I've used something similar to this script before in an older 4.0 site, but I think that this modification is a better way to do it. (i used to have the main if statement inside template1, including template2 if needed).

----

Try it out and tell me if it works.
Glitchy is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Sponsored Links
Old 23.04.2004, 17:33   #22 (permalink)
Junior Mamber
 
Join Date: Apr 2004
Posts: 34
gintas is an unknown quantity at this point
Default Re: Different frontpage template

Quote:
Originally Posted by Glitchy
The best way to do it, (so that you don't change any of the core, is to split your template/name/index.php into three files.
..............
Try it out and tell me if it works.
It works fine. Thanks a lot!
gintas is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 12.05.2004, 17:06   #23 (permalink)
Baby Mamber
 
Join Date: May 2004
Posts: 16
sieve is on a distinguished road
Default Re: Different frontpage template

All,
This thread has been a tremendous help in creating a template I'm working on for a client -- thanks!
There's one thing I'm unclear about though; I'd like to modify the switch so that each 'section' has it's own template, rather than each 'content' item. I've experimented with using the 'sectionid' field in the mos_content table, but it doesn't seem to work. I have several pages within each section, and I'd rather not call out each individually in the switch because it would be a lot of work, and I'll have to modify the switch whenever items are published or unpublished.
How do I use the switch to call out a section, rather than actual content?

Thanks!
sieve is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 13.05.2004, 00:44   #24 (permalink)
Mamber
 
lazarus_bitmap's Avatar
 
Join Date: Apr 2004
Location: Dallas, TX
Posts: 71
lazarus_bitmap is on a distinguished road
Send a message via MSN to lazarus_bitmap
Default Re: Different frontpage template

Ignore the section ID. Pay attention to the item ID -- you may get one or two depending on how you laid out your site and whether you use blog pages. Just watch the second number that shows up in URL's. Like so:

http://www.domain.com/content/blogsection/1/70/
or
http://www.domain.com/content/view/86/72/

70 and 72 are the $itemid's in this example.

Or in non-SEF:

http://domain.com/index.php?option=c...id=1&Itemid=72

It's more clear -- $Itemid=72.

Then build your switch statement around that. Here's an example combined component and content-based (using itemid) switch:



Code:
<?php
defined( '_VALID_MOS' ) or die( 'Oops... Sorry, wrong page.' );

switch ($option) {
   case 'com_frontpage': //show home page template
     include_once ('index_home_page.php');
     break;
	 
      case 'com_search': //show search template
     include_once ('index_search_page.php');
     break;
      
   case 'content':
        switch ($Itemid) {
       
        case '78': //job bank
           include_once ('index_job_bank.php');
        break;   
		
		case '77': //job bank
           include_once ('index_job_bank.php');
        break;   
		
		case '103': //communique
           include_once ('index_communique_page.php');
        break;   
		
		case '71': //communique
           include_once ('index_communique_page.php');
        break;   
		
		case '70': //news
           include_once ('index_news_page.php');
        break;   
		
		case '72': //news
           include_once ('index_news_page.php');
        break;   
		
		case '68': //events calendar
           include_once ('index_events_page.php');
        break;   
		
		case '69': //events calendar
           include_once ('index_events_page.php');
        break;   
          
        default:  // DEFAULT sub page template
          include_once ('index_sub_page.php');
          break;        
          }  // END: case 'itemid'
     
      break;  // END : case 'content'
      
   default:  // DEFAULT FOR ALL
      include_once ('index_sub_page.php');
      break;    
}    
?>
__________________
Jerry Stevenson
----------------
Stevenson Consulting
lazarus_bitmap is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 13.05.2004, 03:55   #25 (permalink)
Baby Mamber
 
Join Date: May 2004
Posts: 16
sieve is on a distinguished road
Default Re: Different frontpage template

Thanks Jerry, I've modified the switch and it appears to be working great, I'm going to add some content and test it. One other question, what table is that itemid stored in?
sieve is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 14.05.2004, 20:25   #26 (permalink)
Mamber
 
lazarus_bitmap's Avatar
 
Join Date: Apr 2004
Location: Dallas, TX
Posts: 71
lazarus_bitmap is on a distinguished road
Send a message via MSN to lazarus_bitmap
Default Re: Different frontpage template

Sorry for taking so long to reply... swamped with work.

$Item id is actually not in the content table -- it's in the menu table under 'id'. Content is called with a reference to the unique content item, and it's related menu. By knowing the menu you're under, you can broadly apply template changes to entire sections of a site. Make sense?
__________________
Jerry Stevenson
----------------
Stevenson Consulting
lazarus_bitmap is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 14.05.2004, 20:50   #27 (permalink)
Baby Mamber
 
Join Date: May 2004
Posts: 16
sieve is on a distinguished road
Default Re: Different frontpage template

No apologies necessary, I appreciate the time you're taking to help!

I think I'm starting to get it; so in the MOS Admin panel, I've defined "sections" under the content menu. Within each section, I have a articles that relate to the section. But if I understand you correctly, I can't switch the template based on a given 'section', but rather I need to add the content items to appropriate menus and code the switch to include the menu a give article is under? That being the case, what's the purpose of defining 'sections' and 'categories'?

Thanks!
sieve is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 14.05.2004, 20:59   #28 (permalink)
Mamber
 
lazarus_bitmap's Avatar
 
Join Date: Apr 2004
Location: Dallas, TX
Posts: 71
lazarus_bitmap is on a distinguished road
Send a message via MSN to lazarus_bitmap
Default Re: Different frontpage template

There may be a way to code a query in the switch for category or section... But I'm not sure what it is. I just know this works. :-) 4.5 wasn't built for template switching out of the box, though 4.6 apparently will be. That's why we all play with these hacks to make it work.

Since this was never a core function or 4.5, the point of sections and categories was simply to more easily organize news, since you can create menu items that relate directly to those major sections or subsections. I think it also allows your blog pages to group categories of items together under a section (assuming you published a blog section). But don't even get me started on the way it does sorting... :-)
__________________
Jerry Stevenson
----------------
Stevenson Consulting
lazarus_bitmap is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 14.05.2004, 21:10   #29 (permalink)
Baby Mamber
 
Join Date: May 2004
Posts: 16
sieve is on a distinguished road
Default Re: Different frontpage template

That explains a lot --

It's working well, I'm trying to take the next step from copying/pasting to understanding what the code is doing. (So I'll stop asking dumb questions!!)

Thanks again for your help.
sieve is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 15.05.2004, 05:46   #30 (permalink)
Baby Mamber
 
Join Date: May 2004
Posts: 16
sieve is on a distinguished road
Default Re: Different frontpage template

ok, let me hit you with my next challenge;

I'm trying to take the code you gave me to the next level. Rather than pull up separate templates based on the content, I want to set it up with only one template that has variable names for the specific images that need to load:

Here's what I have so far:

...
case '26': //first area
$image="images/image1.gif";
include_once ('index-var.php');
break;

case '27': //second area
$image="images/image2.gif";
include_once ('index-var.php');
break;

case '28': //area 3
$image="images/image3.gif";
include_once ('index-var.php');
break;

...

and in index-var.php, I have

.....
<td width="18%" align="left"><img name="templateimage" src=$_GET['image'] width="140" height="85" alt=""></td>
.....

It doesn't work. Am I passing it wrong, or "GET"ting it wrong? My understanding of the Include statement is all variables present in the first file will be available to the second file, so I reasoned if I create the link in the switch, I should be able to access it in the index-var.php What am I missing?

One other real small thing; I've noticed on some sites that the tables resize depending on how big the browser window is (within limits). Usually the sidebars stay pretty constant while the middle table adjusts. I've tried to do that by setting the middle table width to a % of the screen, but it doesn't seem to work. Is there a trick to making that work?

Last edited by sieve; 15.05.2004 at 20:31.
sieve is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Template modules TheGreek Template Discussions 10 08.04.2004 00:27


All times are GMT +2. The time now is 09:43.

Powered by vBulletin® Version 3.7.2
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.1.0
A vBSkinworks Design
© Copyright 2004-2008 by Arthur Konze Webdesign.