View Full Version : List them articles
utvara
04-05-2007, 12:12 PM
The Disk is flat, we all know it. :) and this is how to build article list.
If you want to produce custom boxes, output lists, or generate literally any desired output of articles, here's a detailed HOW-TO.
Article list generating
Article_list::search explained
/**
* Advanced search list generator
*
* @param array $params Search parameters
* @param string $order Order parameters
* @param integer $limit Limit
* @param integer $offset Offset
*/
Article filter (search parameters)
a.id - Select article by id
a.cid - Select articles in category (single id)
a.created - Select articles prior to date/time (date format '2007-03-31 01:15')
title_body - Select articles containing phrase (MySQL full text search limitations apply to this filter)
a.category_id - Select articles in categories (comma separated category ids)
year - Select articles by year
month - Select articles by month
day - Select articles by day number
a.status - Select articles by status (0 or 1)
search_date - Select articles by date interval (ie. 7 days) expecting also search_date_direction ('before'/'after')
author_exact - Select articles by exact author name
author_like - Select articles by author name like
related - Select articles related to article, expects article id
a.featured_news - Select articles featured status (0 or 1)
rss_feed - Select articles rss publishing status (0 or 1)
Article order (Order parameters)
most_popular - Order by most popular
most_emailed - Order by most emailed
most_commented - Order by most commented
relevance - Order by relevance (applies only to filtering by related)
title - Order by title
author - Order by author name
date - Order by creation date ascending
date_desc - Order by creation date descending
order_desc - Order by user set order descending (default order)
rand - Random order
rank - Order by rank (applies only to filtering by title_body)
Example 1. (latest news)
$article_list = new Article_list();
$article_list->search(
array(
'a.status' => 1, // Only articles with status 1 (published)
'a.created' => $cur_date, // Only articles 'created' before current time
'a.featured_news'=> '0' // Exclude featured news
),
'order_desc', // Order results by default order
'', // Direction tweaking (for customization only)
$latest_news_number, // Number of articles to list
0 // Start from article (counter starts from zero)
);
utvara
04-05-2007, 12:17 PM
Rincewind went over the edge, and came back. Lady had something to do with that.
Formating article list
/**
* Generic article list
*
* @param mixed $article_list Article list object/false
*
* @param string $box_template HTML list enclosure template
* @param array $box_params Box related params
* @example array('BOX_TITLE' => 'Title', 'BOX_ID' => 'box_most_something', 'ICON' => 'foo.png', 'BOX_WIDTH' => '32.5%', ...)
*
* @param string $article_template HTML article template
* @param array $article_params
* @example array('word_number' => 40, 'image_width' => 0, 'image_height' => 0, 'columns' => 1, ...)
*
* @param array $params Search restriction params array @see '../../Class/Article.class.php'
* @param string $order Search order
* @param string $direction Search order direction ('ascending'/'descending')
* @param integer $limit Search limit (number of articles)
* @param integer $offset Search offset (start from article)
*
* @return string Formated article list
*/
Example 2.
$box_most_emailed_HTML = HTML_article_list(
false, // No pregenerated article list
'box_article_list.tpl', // Box enclosure template (located in templates/content)
array( // Box template param
'BOX_TITLE' => $lang['LNG_MOST_EMAILED'], // Each array key coresponds to vivvo template tag
'BOX_ID' => 'box_most_emailed'
),
'article_title.tpl', // Single article template (located in templates/content/summary)
array(), // Article template tweaks
array( // Article filter
'a.status' => 1, // Only published
'a.created' => $cur_date // Only articles 'created' before current time
),
'most_emailed', // Order by times emailed
'',
4 // Number of articles
);
utvara
04-05-2007, 12:22 PM
Templates
Box enclosure template tags
{ARTICLE_LIST} // Only true template tag, other tags are dynamically added from box template param
Example (Box enclosure template)
<div id="{BOX_ID}" class="box_right">
<div class="box_title"><h3>{BOX_TITLE}</h3></div>
<div class="box_line">
<!-- -->
</div>
<div class="box_body">
<ul>{ARTICLE_LIST}</ul>
</div>
</div>
Single article template (tags)
{BOX_WIDTH} // For multi column layouts
{ROOT} // Vivvo root url
{LINK} // Article relative link
{CAPTION_TITLE} // Article title
{AUTHOR} // Author name/link (depends on preferences setting)
{CREATED} // Article creation time (formated according to preferences setting)
{IMAGE} // Article image filename
{IMAGE_WIDTH} // Image width
{IMAGE_HEIGHT} // Image height
{BODY} // Article summary
{REDIRECT_LINK} // Redirect link (depends on type of article)
{REDIRECT_CAPTION} // Redirect caption (depends on type of article)
Example (Single article template)
<div class="short" style="width:{BOX_WIDTH};">
<h3><a href="{ROOT}{LINK}">{CAPTION_TITLE}</a></h3>
<span class="article_date">{AUTHOR} {CREATED}</span>
<div class="summary">
<div class="image">
<a href="{ROOT}{LINK}">
<img src="{ROOT}files.php?file={IMAGE}" width="{IMAGE_WIDTH}" height="{IMAGE_HEIGHT}" alt="image" />
</a>
</div>
{BODY}
<div class="article_link">
<a href="{REDIRECT_LINK}">
{REDIRECT_CAPTION}
<img src="{ROOT}templates/img/left_navi_arrow.gif" alt="" />
</a>
</div>
</div>
</div>
Assigning to template manager
$template_manager->assign($box_most_emailed_HTML,'/{BOX_MOST_EMAILED}/'); // Assign value of $box_most_emailed_HTML to BOX_MOST_EMAILED tag
utvara
04-05-2007, 12:24 PM
Example 3. (Last week posts)
$article_list = new Article_list();
$article_list->search(
array(
'a.status' => 1,
'a.created' => $cur_date,
'search_date' => 7,
'search_date_direction' => 'after'
),
'date_desc',
'',
10,
0
);
$last_week_short_HTML = HTML_article_list(
$article_list,
'content_article_list.tpl',
array(
'BOX_TITLE' => 'Last week news',
'BOX_ID' => 'box_last_week_list'
),
'article_short.tpl',
array(
'image_width' => $latest_news_image_width,
'word_number' => $latest_news_word_number
)
);
$template_manager->assign($last_week_short_HTML, '/{LAST_WEEK}/');
pcoskat
06-02-2007, 12:30 PM
In a sidebar 'box', I'd like to randomly display ONE headline + summary that is pulled from one specific category.
In a nutshell, can you confirm that something up ^there^ will allow me to do this? (I'm not a coder, and will have to pass this onto the developers. I just want to make sure I don't need to ask them to custom code anything)
thanks!
Yes, exactly. This is doable by using this How-To.
pcoskat
06-04-2007, 11:59 AM
great!
is there a way to avoid having the link to the 'random' category appear in the navigation menu?
kazantrop4ik
06-21-2007, 11:54 AM
please, explain more about LAST WEEK articles,
and provide more details from start to end
vivvocms
06-21-2007, 04:19 PM
hi,
i want to know how to make custom box(tpl).
in previous version(3.4) in this forum it was explained very clearly step by step. But in this version it is explained just for article boxes.
But i want to add a module which shows money exchange (dollar & euro) which reads from my custom table.
i know how to implement its php side, but i dont know how to assign and use it like vivvo boxes. it limits me very much please help me.
can you explain it and its details step by step like in previous version?
vivvocms
06-22-2007, 06:19 PM
Why do not you answer the questions?
andy77
06-22-2007, 08:21 PM
But in this version it is explained just for article boxes.
But i want to add a module which shows money exchange (dollar & euro) which reads from my custom table.
i know how to implement its php side, but i dont know how to assign and use it like vivvo boxes.
A box is a box... This tutorial applies to creation of any type of boxes. Just follow the explanation. Don't expect to get it on a silver plate :)
vivvocms
06-22-2007, 09:51 PM
A box is a box... This tutorial applies to creation of any type of boxes. Just follow the explanation. Don't expect to get it on a silver plate :)
I am waiting for the answer of support team.
That is none of your business.
If so they will write it here. Why do you feel yourself
responsible for answering when your answer does not help me?
Criticalmass24
07-23-2007, 03:05 AM
that is confusing as fuck... i just wanna add a block and stick some links in it.
utvara
07-23-2007, 05:11 PM
For howto make simple box in v3.5 checkout this http://www.vivvo.net/forums/showthread.php?t=1110
MemoBony
08-06-2007, 03:38 PM
A box is a box... This tutorial applies to creation of any type of boxes. Just follow the explanation. Don't expect to get it on a silver plate :)
Sorry my dear andy. but WHY not? I think you did't already, because you are very smart and know the codes much better than the rest here. So, it will be very nice from you to share your experience if you write exactly how you did it before (step by step) and it will be very helpfull for many of dommies here. And also helpfull for the Vivvo team.
Is that not better than instead of a mockery of someone.
And this is an invitation also for the handsum pcoskat, I saw how you did't with your website, it's very nice! By the way, I saw how you was fat and how you are now so handsum, it's great what you have done man. Cheers :)
Thanks for all of you.
pcoskat
08-06-2007, 04:10 PM
And this is an invitation also for the handsum pcoskat, I saw how you did't with your website, it's very nice!
Thank you!!! BTW, I had to hire an outside team to do this. It was much too complicated for me...
khabaru
08-07-2007, 03:38 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.
vBulletin® v3.8.4, Copyright ©2000-2012, Jelsoft Enterprises Ltd.