PDA

View Full Version : The additional latest news box


jasmina
08-06-2007, 03:27 PM
How to create the additional latest news box in two columns :

1. Go to the file /include/box_definitions.php and add the code below:

$article_list = new Article_list();
$article_list->search(array('a.status' => 1, 'a.created' => $cur_date, 'a.featured_news'=> '0' ), 'order_desc', 'descending',4, 3);
$latest_news_HTML = HTML_article_list(
$article_list,
'content_article_list_no_title.tpl',
array('BOX_ID' => 'box_two_column'),
'search_result.tpl',
array('image_width' => $latest_news_image_width, 'word_number' => 20, 'columns' => 2)
);
$template_manager->assign($latest_news_HTML,'/{BOX_TWOCOL_LATEST}/');
The next line:

$article_list->search(array('a.status' => 1, 'a.created' => $cur_date, 'a.featured_news'=> '0' ), 'order_desc', 'descending',4, 3);defines the list of objects. The 'order_desc' variable defines the order of objects in the list. The latest two variables, in this example 4 and 3, show how many objects you will group by columns and from which one you will start.

The code line for the global template is:
'content_article_list_no_title.tpl', The individual template is defined with:
'search_result.tpl', In the code line:
array('image_width' => $latest_news_image_width, 'word_number' => 20, 'columns' => 2)the variable 'image_width' is used to determinate the width of the picture. The next one, 'word_number' defines the allowed number of words. You can set the number of columns, If you change the value of the 'columns' variable . For example, if you change this into 3, you will have 3 columns of articles instead of 2.

2. In the file /templates/index.tpl you need to add the tag you created:
{BOX_TWOCOL_LATEST}

khabaru
08-07-2007, 03:28 AM
hey, its nice feature you discovered. but i guess, if both latest news blocks can contain deferent articles. example: the normal latest news columns will display most reasont articles while the additional latest news block displays the rest of latest news. so in other words both bolocks not to display duplicate articles. also how about writing a code for this additional latest column, not to include articles that are already displayed on general latest block?. cheer...

khabaru
08-07-2007, 03:39 AM
hi, I am gonna create an additional (alternative) latest news clomn on the hompage, but i need to exclude articles that are already displaying on the main latest news colum. I gues can do it, example in this thread this code is used not to display featured news on latest news block,*** 'a.featured_news'=> '0' *** . can anyone help me to use exclude code for my new box?. and also I need to display only titles of the articles on this new alternative latest news column. pls help yah. cheear.

jasmina
08-07-2007, 10:30 AM
If you want to display each article just once, to exclude the article which is already displayed on the Latest news block, you must adjust some variables in the code line below:

$article_list->search(array('a.status' => 1, 'a.created' => $cur_date, 'a.featured_news'=> '0' ), 'order_desc', 'descending',4, 3);


In this example, number 3 points that your list starts from the fourth article (counter starts from zero), and the second number, in this example 4, shows the number of articles in the list.

If you need to show only the title of the article just create a new template in /templates/content/ folder which will provide this and use that template instead of the one is used, in this example:

'search_result.tpl'

khabaru
08-09-2007, 05:58 AM
thanks Jasmina. i tried ur instruction, but it still confusing me. cud pls tell me simply how to use a simple box on home page and display "titles" of all latest news exept artcle that already displaying in feature news and main latest news column.

Tobes
09-12-2007, 05:25 PM
Hi Jasmina,

This is the kind of code Im looking for, but is it possible to have one column for latest news, and the other column for a catagorie of my choice.

I would really appreciate your help, if you know how to do this, your experiance would be greatly appreciated.

Tobes

edit:

oh im sorry, is this for the latest news shown on the home page in the center, not the latest news on the right side column?

Im needing two latest news catagories columns on the home page :)