| | | |  |  | |  |
19.05.2004, 18:15
|
#31 (permalink)
| | Mamber
Join Date: Apr 2004 Location: Dallas, TX
Posts: 71
| Re: Different frontpage template The problem you're hitting is that the variable ($image) doesn't get passed from index.php to index-var.php. I'm not a PHP guru, and I'm not sure whether the include_once function allows you to pass arguments.
But the point of this approach is really using entirely different layouts, not just altering images.
If it were me, I'd integrate the switch statement directly in to the template. That way you don't have to bother with passing variables. Or you could combine both approaches -- use the example here to call one type of template for particular pages that uses the in-template image switch, and other templates that don't. Also, if your image is a header, you could make that area of your template a custom module (user1, user2, etc.) that simply calls different images depending on where they are on your site -- do a search on the mamboserver forum for that. It's been brought up before.
On the second question, the sites you're viewing are using variable width templates. Usually they work by making left/right modules fixed pixel width, with the center column at 100%. You also have to make sure that the table containing the entire layout opens up to 100%... It a bit tricky, and the best way to do it is to copy the work of an existing variable width template like Peaklime. |
| |
19.05.2004, 20:39
|
#32 (permalink)
| | Professional Mamber
Join Date: Apr 2004 Location: Gap / France
Posts: 860
| Re: Different frontpage template Quote: |
Originally Posted by sieve 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? | do this: PHP Code: case '26': //first area
$image="images/image1.gif";
break;
//and where you want the image:
<td width="18%" align="left"><img name="templateimage" src=$image width="140" height="85" alt=""></td>
same as in the thread about different header images..works like a charm, either with just the "option" switch, or even adding sub-switches for content to check which section you're in.. |
| |
23.11.2004, 19:24
|
#33 (permalink)
| | Mamber
Join Date: Apr 2004
Posts: 123
| Re: Different frontpage template hi,
thanks for your contributions,
however all the codes above only apply for items id?
not for sections?
any advice? |
| |
23.11.2004, 19:39
|
#34 (permalink)
| | Mamber
Join Date: Apr 2004 Location: Dallas, TX
Posts: 71
| Re: Different frontpage template First, keep in mind this is only a 4.5.0 hack. It's an old workaround to a problem that shouldn't exist in the new version. 4.5.1 has built in template switching and is a much easier way to do it. Don't ask me how, as all my sites are currently still on 4.5.0.
Having said that, read careful through page 2 of this thread. The terminology makes things a bit confusing.
Itemid does not relate to individual items; it relates to how you set up the 'main menu' for your site. So, if you make one of your menu items a news section, you can simply look at the URL to determine the itemid (it will show up on all the stories under the section). Code the switch statement using that itemid, and you'll end up having a template switch that corresponds to whatever section you want. |
| |
08.05.2006, 07:24
|
#35 (permalink)
| | Baby Mamber
Join Date: May 2006
Posts: 2
| Re: Different frontpage template Hi,
I followed the suggestion and put the code on page 2. into index.php (in the template) and zip all the php file (index_homepage.php, index_subpage.php, index.php) and other files. Then I installed the template. However, the frontpage appears as two pages which basically stack up the same content below the original one. I am not sure what I have done wrong. This is the code I used. Code: <?php
defined( '_VALID_MOS' ) or die( 'Oops... Sorry, wrong page.' );
switch ($option) {
case 'com_frontpage': //show home page template
include_once ('index_homepage.php');
break;
default: // DEFAULT FOR ALL
include_once ('index_subpage.php');
break;
}
?> My work is here http://symbiont.co.nz. It works fine now as I have taken the code off and put up only one template. Basically what I want to do is that on the front page the news and update box will show on the right hand side. For all others sections it will not show up and I might put in a random image module to replace that.
I am new to this CMS. Any suggestion is very much appreciated.
Thank you for reading. |
| |
08.05.2006, 07:31
|
#36 (permalink)
| | Mamber
Join Date: Apr 2004
Posts: 123
| Re: Different frontpage template |
| |
08.05.2006, 23:31
|
#37 (permalink)
| | Baby Mamber
Join Date: May 2006
Posts: 2
| Re: Different frontpage template Thank you panter011. I will try that out. Thanks. |
| |
10.07.2006, 07:28
|
#38 (permalink)
| | Baby Mamber
Join Date: Jul 2006 Location: New Zealand
Posts: 15
| Re: Different frontpage template thanks panter011 |
| | | Thread Tools | | | | Display Modes | Linear Mode |
Posting Rules
| You may not post new threads You may not post replies You may not post attachments You may not edit your posts HTML code is Off | | |
Similar Threads | | Thread | Thread Starter | Forum | Replies | Last Post | | Template modules | TheGreek | Template Discussions | 10 | 07.04.2004 23:27 | All times are GMT +2. The time now is 03:40. | | | |