|
I have actually been approached several times asking how to insert an image separator or a <hr> tag between news/articles on the frontpage. Click here to see example. Just so coincidentally, a client of mine actually wanted to do this and a person named Rey Gigataras from Queensland, Australia wrote a small article for him on how to achieve this.
I obtained a copy of this article and wrote to him about having this article published at MamboHut for the benefit of everyone. So, here it is. With slight modification, his article is presented the way (almost) it was originally written.
Please note: I am assuming that you are using at least Mambo 4.5 1.0.0. This article does not guarantee success in every case. It is only a suggestion and you should always back up your files in case anything goes wrong. The author or Mambohut shall not be held liable for any damages or losses caused by the changes listed here.
You will need to open and edit the following file • components/com_frontpage/frontpage.php
*For this solution you do not need to delete anything, you simply insert a few lines of code. PLEASE BACKUP A COPY FIRST*
The code that we need to manipulate starts at Line 99 and goes to Line 123. It looks like this:
...
// Leading story if ($col==3) { echo "<tr>n"; echo "<td valign="top" colspan="2">n"; show( $rows[$i2], MASK_READON|$image, $option ); echo "</td>n"; echo "</tr>n"; $i2++; $n2--; $intro2--; }
for ($i=0; $i < $n2; $i++) { if (!($i%2) || $col==1) { echo "<tr>n"; } echo $col==1 ? "<td valign="top">n" : "<td width="50%" valign="top">n"; if ($i < $intro2 || $intro==0) { show( $rows[$i+$i2], MASK_READON|$image, $option ); } else { HTML_content::showLinks( $rows, $intro, $n ); echo "</td>n</tr>n"; break; } echo "</td>n";
...
Solution A If you simply want to place a divider between the news articles the code should look like this:
Lines to insert are commented and in BOLD.
...
// Leading story if ($col==3) { echo "<tr>n"; echo "<td valign="top" colspan="2">n"; show( $rows[$i2], MASK_READON|$image, $option ); echo "<hr width='50%'><br/>"; // <--- Insert this line or replace with image if you have one echo "</td>n"; echo "</tr>n"; $i2++; $n2--; $intro2--; }
for ($i=0; $i < $n2; $i++) { if (!($i%2) || $col==1) { echo "<tr>n"; } echo $col==1 ? "<td valign="top">n" : "<td width="50%" valign="top">n"; if ($i < $intro2 || $intro==0) { show( $rows[$i+$i2], MASK_READON|$image, $option ); } else { HTML_content::showLinks( $rows, $intro, $n ); echo "</td>n</tr>n"; break; } echo "<hr width='50%'><br/>"; // <--- Insert this line or replace with image if you have one echo "</td>n";
...
Solution B I believe a more sophisticated solution to this problem is to assign a css class to the news articles so you control how they look from the template_css.css file. This allows you to place borders, change the background color and other options to make your articles standout from each other
Lines to insert are commented and in BOLD.
...
// Leading story if ($col==3) { echo "<tr>n"; echo "<td valign="top" colspan="2">n"; echo "<div class='frontpage-news_table'>"; // <--- Insert this line show( $rows[$i2], MASK_READON|$image, $option ); echo "</div>"; // <--- Insert this line echo "</td>n"; echo "</tr>n"; $i2++; $n2--; $intro2--; }
for ($i=0; $i < $n2; $i++) { if (!($i%2) || $col==1) { echo "<tr>n"; } echo $col==1 ? "<td valign="top">n" : "<td width="50%" valign="top">n"; echo "<div class='frontpage-news_table'>"; // <--- Insert this line if ($i < $intro2 || $intro==0) { show( $rows[$i+$i2], MASK_READON|$image, $option ); } else { HTML_content::showLinks( $rows, $intro, $n ); echo "</td>n</tr>n"; break; } echo "</div>"; // <--- Insert this line echo "</td>n";
...
Then in the template_css.css file create the css class .frontpage-news_table and assign the properties you wish to it. Have fun!
If you have any problems, please post them at the forums. Thank you.
Mr Rey Gigataras's web address: http://www.utra.org.au. Do drop him a note of thank you if you find this article useful.
|
Thanx! Written by Guest on 2004-05-25 06:02:38 Very helpful article, thank you! | cheers Written by Guest on 2004-07-02 10:22:02 just what I was looking for, ta http://www.djsource.co.uk | Written by Guest on 2004-07-06 04:10:42 | 4.5.2.x Written by wyzemoro on 2005-03-21 05:26:24 how to do this on 4.5.2.x? | Many thnx! Written by gogz on 2005-05-23 06:07:31 The only really useful solution on the Web... Btw in Mambo 4.5.1 and 4.5.2 you have to edit the following file: components/com_content/content.php GoGz | Written by Guest on 2005-08-02 18:30:19 Is this still possible in 4.5.2.. please some help | Written by Sssst on 2005-08-26 09:05:16 In components/com_content/content.phpfunction Show has to be changed. Add the line "echo ""; // call( 'HTML_content::show', $row, $params, $access, $page, $option, $ItemidCount );" to get a line just before or afte the item. | Written by Sssst on 2005-08-26 09:10:38 sorry, my previous comment has been scrambled. Next try. The solutions described above will also work in mambo 4.5.1 and later. Adjust function "Show" in file "components/com_content/content.php". Try this solution beofre or after the line "call( 'HTML_content::show', $row, $params, $access, $page, $option, $ItemidCount )". | Written by techit on 2005-10-10 18:43:37 For those using mambo 4.5.2 and are unsure I made a page with info of my code and comments. It might help you understand. http://techit.org/index.php?option=com_content&task=view&id=20 Also if any one knows how to have each news on the homepage to have it own table around it I would like to know how to do that. Thanks! |
Only registered users can write comments. Please login or register. Powered by AkoComment 2.0! |