PDA

View Full Version : Article List Generator


berto
10-09-2007, 05:08 PM
Would it be at all possible to some how use the ARTICLE LIST GENERATOR inside an actual article and not on a template?

This will help tremendously in what we want to achieve with Vivvo.

utvara
10-09-2007, 08:08 PM
Well Article generator wizard can't be used inside article, since articles aren't processed by VTE. But if you can elaborate your problem, maybe we can help you figure out the solution you are seeking.

berto
10-09-2007, 08:36 PM
Like I mentioned to you on the Tags post I created (U2 :) ) I run a music website so we are creating artist profiles.

Why I asked if the Article Generator was able to work within articles was because we wanted to generate lists that relate to the artist since the generator has the ability to do that by generating lists of your choice, whever it be by keywords, tags, sections etc.

If I have for instance the artist AMY WINEHOUSE -

I would created a list to search amy winehouse under cat news, then create another list in cat reviews and another in cat videos and then simply paste the code within the article where i want the lists to appear. I have attached an image so you get a better understanding.

I am sure this can be done easy by using templates but could you imagine the amount of tamplates I would have to create? How many artist are out there :eek:

Thanks for your time

boccio
10-09-2007, 08:48 PM
I suggest you use Metallica as an example, he might be more willing to help you out :D

berto
10-09-2007, 08:50 PM
Dnt worry they are in there somewhere! :D

utvara
10-09-2007, 09:56 PM
Article list generator is just a helping tool you don't have to be bound by it.

I was gonna go to rehab, bu I joined Spoonlabs instead... :cool:

First I would suggest creating a custom template for artist article (let's call it artist.tpl) it must be located in templates/xhtml/article/.

Now let's work on it, shall we...

Keyword we wanna use is amy_winehouse in Reviews category (for sake of conversation I assume that Reviews category id is 2). Than means that our restrictions are

search_tag = "amy_winehouse"
and
search_cid = "2" (cid stand for category id)

Problem remains how to make "Amy Winehouse" (I presume that that is the title of article) into "amy_winehouse".... VTE can't help us out there so we'll have to go back to php:

function make_tag_out_of_title($title){
$title = explode (' ',strtolower($title));
return implode('_', $title);
}

You should put this function in my_functions.php and include that file in index.php at a beginning.

Now there are two way to combine this with output template, I'm going with the harder one :)

<vte:box module="box_article_list">
<vte:params>
<vte:param name="search_sort_by" value="created" />
<vte:param name="search_limit" value="5" />
<vte:param name="search_tag" value="{article.get_title|make_tag_out_of_title}" />
<vte:param name="search_cid" value="2" />
</vte:params>
<vte:template>
<div id="artist_review">
<h3>{article.get_title} in Reviews</h3>
<ul>
<vte:foreach item = "review_article" from = "{article_list}">
<li>
<a href="{review_article.get_href}">
<vte:value select="{review_article.get_title}" />
</a>
</li>
</vte:foreach>
</ul>
</div>
</vte:template>
</vte:box>

That should be the Review box, other boxes are done in similar fashion.

Now just the question of where to put this :)

According to your screen shot you don't have anything but link boxes. Now that just ain't fair ;) you should put little biography in article body or abstract. So my opinion is that you new custom box should go somewhere below <vte:value select="{article.get_body}" />.

Try it out.

utvara
10-10-2007, 12:07 PM
Here's some extra juice for our site ;)

I've used last.fm for a while, so that's the first place I would look for a chart on Amy (or Metallica :) ), but here is how to add that chart to your site...

Nice people from last.fm are wiling to share their data under CC license.

So let's take a look at http://ws.audioscrobbler.com/1.0/artist/Metallica/toptracks.xml , notice that this is xml file, we dont't have xml importer for Vivvo (yet)....

So here goes the grabber

class box_xml_grabber extends module {
var $data;

function object2array($object){
$return = NULL;

if(is_array($object)){
foreach($object as $key => $value){
$key = str_replace('@', '_', $key);
$return[$key] = $this->object2array($value);
}
}else{
$var = get_object_vars($object);
if($var){
foreach($var as $key => $value){
$key = str_replace('@', '_', $key);
$return[$key] = $this->object2array($value);
}
}else{
return strval($object); // strval and everything is fine
}
}

return $return;
}

/**
* Generate box output
*
* @param array $params Parameters
*/
function generate_output($params){
$this->set_template($params);
if ($params['url'] != ''){
$data = @simplexml_load_file($params['url']);
if ($data){
$this->data = $this->object2array($data);
$this->_template->assign('xml_data', $this->data);
}
}
}
}

This box module can be used generally to fetch xml data. It relies on simplexml extension (PHP 5) and remote fopen being allowed.

Now we have to register new module in configuration table:

INSERT INTO `tblConfiguration` ( `id` , `variable_name` , `variable_property` , `variable_value` , `module` , `domain_id` , `reg_exp` )
VALUES (NULL , 'box_xml_grabber', 'class_name', 'box_xml_grabber', 'modules', '1', NULL),
(NULL , 'box_xml_grabber', 'file', 'my_boxes.php', 'modules', '1', NULL);

You'll have to do this manually (from phpMyAdmin, or something ...)

And finally the template:

<vte:box module="box_xml_grabber">
<vte:params>
<vte:param name="url" value="http://ws.audioscrobbler.com/1.0/artist/Metallica/toptracks.xml" />
</vte:params>
<vte:template>
<div class="box">
<div class="box_title_holder">
<div class="box_title">
<vte:foreach item="attr" from="{xml_data[_attributes]}"><vte:value select="{attr}" /></vte:foreach> @ last.fm
</div>
</div>
<div class="box_body">
<div class="box_content">
<ul>
<vte:foreach item="track" from="{xml_data[track]}" loop="10">
<li><vte:value select="{track[name]}" /> (<vte:value select="{track[reach]}" />)</li>
</vte:foreach>
</ul>
</div>
</div>
</div>
</vte:template>
</vte:box>

I suggest putting this template in right column on artist article page.

For adjusting url to audioscrobbler you can use similar method I previously discussed for title to tag conversion.

berto
10-10-2007, 05:43 PM
Top man Utvara got more than I was looking for. Thanks very much for your help, will indeed let you know how it all goes.

Thank you.

One question regarding the my_functions.php - is this a file I create cause there is no such file in the vivvo package.

Thanks again:) :cool:

utvara
10-10-2007, 06:45 PM
Yes my_functions.php is a new file, and I recomend ou all keep your custom work in your own files (becouse of future upgrades). So I wan't mess up your code :D

berto
10-10-2007, 08:01 PM
Thanks Utvara.

Is it me? Your code keeps appearing at the top of the page like so when I include it:

function make_tag_out_of_title($title) { $title = explode (' ',strtolower($title)); return implode('_', $title); }

utvara
10-11-2007, 11:49 AM
did you by any chance forget to put <?php ?> around it?

berto
10-11-2007, 05:18 PM
Utvara your first code did not seem to work?

Altough I changed {article.get_title|make_tag_out_of_title} to {article.get_title_make_tag_out_of_title} as it did not work. It then retrieved titles but they did not relate to the artist (in this case amy winehouse)

I tried it another way (see code below) and it seems to be working fine, altough they need to be spaced out better.

What you reckon? Code ok?

Demo (http://www.buenatv.co.uk/rock_and_pop/rock_and_pop_artists/amy_winehouse.html)

<vte:box module="box_article_list">
<vte:params>
<vte:param name="search_sort_by" value="created" />
<vte:param name="search_limit" value="5" />
<vte:param name="search_query" value="{article.get_title}" />
<vte:param name="search_title_only" value="1" />
<vte:param name="search_cid" value="2" />
</vte:params>
<vte:template>
<div id="artist_review">
<h3><vte:value select="{article.get_title}" /> In THe News</h3>
<ul>
<vte:foreach item = "review_article" from = "{article_list}">
<li>
<a href="{review_article.get_href}">
<vte:value select="{review_article.get_title}" />
</a>
</li>
</vte:foreach>
</ul>
</div>
</vte:template>
</vte:box>

utvara
10-12-2007, 06:00 PM
OK that can do the trick. I would just enable caching to prevent this queries being executed to often.

By the look of your demo, seems you're getting along with VTE ;)

Hope to finish VTE documentation soon...

berto
10-13-2007, 05:39 PM
Yes will do when the site goes live.

Yeah getting to grips with the VTE :) neat stuff.

berto
12-04-2007, 04:58 PM
OK that can do the trick. I would just enable caching to prevent this queries being executed to often.

By the look of your demo, seems you're getting along with VTE ;)

Hope to finish VTE documentation soon...

Would I need to add the CACHE="1" to all my boxes or just by turning it on in the admin panel will be enough?

Micha
12-05-2007, 08:55 AM
You need to add CACHE="1" param on every box/module you want cached.
If you turn off caching from your admin panel, there will be no caching trough system regardless where you placed CACHE="1" param.

So the conclusion would be, you need to have cache turned on in administration and CACHE="1" param on box/module you want to cache.

pb_jam
01-02-2008, 06:38 PM
Does anyone know how i might accomplish this?

I'd like to create a list that ONLY displays articles which have the same tag as the article that is currently being viewed (I want to use tags as another way to relate articles). I understand that for this to work with multiple tags might be more complicated, so I'd be happy to get this working with the restriction that only one tag may be assigned to each article.

I've tried to do this with the article generator as well as a template similar to the "related news" box. The only problem I am having is dynamically retrieving the tag from the current article and using that as one of my search parameters.

Here is the parameter portion of my template:

<vte:params>
<vte:param name="search_sort_by" value="created" />
<vte:param name="search_limit" value="5" />
<vte:param name="search_tag" value="tag_from_current_article_here" />
</vte:params>

It works fine if I hard code a value for search_tag. I just don't know how to go about retrieving the tag from current article.

Thanks

utvara
01-03-2008, 10:45 AM
It is simpler if you use related articles for this. Pleaser refer to online documentation on how to tweak article relating.

http://www.vivvo.net/doc/v4/user_manual/preferences_articles.php

Hope this helps.

As for your question about getting the tags out, there is no easy way out that one.

pb_jam
01-03-2008, 05:23 PM
Thanks for your reply. I had originally planned to use the related articles box to list articles with similar tags, but in my admin I am unable to set the CATEGORY relevance to "0" -- every time I try to save with this category setting, it automatically reverts to "5". I would like only articles with matching tags to be listed on a given page, and I have had little success with this so far when using related articles. Do you have any suggestions?

Thank you.