1
patagon
Another article 1.0 question
  • 2007/7/15 4:28

  • patagon

  • Quite a regular

  • Posts: 235

  • Since: 2002/1/8 0


Hi,

I would like to display in the category view of article (template is called article_inc_category.html if it helps) one of the fields that article stores. I figured it was as easy as copying one of the existing fields on that template, for example:

<{$article.title}>

and name the last part after the value I want to display, in this case:

<{$article.source}>

but for whatever the reason this doesnt work. in form.article.config both these values are specified:

$form_art_elements["custom"] =
array(
...
"art_image", // Article spot image
...
"art_source", // Original source
);

and article.source shows the value on other templates, but not on this one (while article.image, and article.time for example do). I guess I'm missing something, but I dont know where to look...any help is appreciated

2
patagon
Re: Another article 1.0 question
  • 2007/7/16 3:01

  • patagon

  • Quite a regular

  • Posts: 235

  • Since: 2002/1/8 0


up

3
Tobias
Re: Another article 1.0 question
  • 2007/7/20 5:49

  • Tobias

  • Not too shy to talk

  • Posts: 172

  • Since: 2005/9/13


<{$article.source}> is a smarty variable that is probably not defined at that point. It's not the content of the database, but a variable that would have to be defined and populated in the corresponding php script.

It seems to me that we're talking about view.category.php here. Now, it's late at night, and I'm tired. But off the top of my hat (or head really), it looks to me like it might make sense to try out the following:

1.) Locate view.category.php line 128
$tags = array("uid""writer_id""art_title""art_summary""art_image""art_pages""art_categories""art_time_publish""art_counter""art_comments""art_trackbacks");

and insert "art_source" after "writer_id" (that's to fetch the value from the database)

2.) Locate view.category.php around line 164:
$_article = array(
        
"id"        => $id,
        
"title"        => $articles_obj[$id]->getVar("art_title"),
        
"author"    => @$users[$articles_obj[$id]->getVar("uid")],
        
"writer"    => @$writers[$articles_obj[$id]->getVar("writer_id")],
        
"time"        => $articles_obj[$id]->getTime($xoopsModuleConfig["timeformat"]),
        
"image"        => $articles_obj[$id]->getImage(),
        
"counter"    => $articles_obj[$id]->getVar("art_counter"),
        
"comments"    => $articles_obj[$id]->getVar("art_comments"),
        
"trackbacks"=> $articles_obj[$id]->getVar("art_trackbacks")
        );

and insert the following line wherever you like. Make sure that each but the last of the similar lines ends with a comma:
"source"    => $articles_obj[$id]->getVar("art_source"),

(that's to assign the value to the variable)

Now try again if you get anything to show if you drop <{$article.source}> into the template as you've done before.

Please remember that you have to update the module everytime you change a template. If you change a php script, you don't have to update the module for the change to be reflected.

This is looking onto the situation through two tired eyes and without any evidence it might work other than a very rough guess. Let me know if it works. If not, I might have a closer look at it one of these days.
www.affvu.org

4
Tobias
Re: Another article 1.0 question
  • 2007/7/21 19:45

  • Tobias

  • Not too shy to talk

  • Posts: 172

  • Since: 2005/9/13


Little correction:

Modify index.php, NOT view.category.php. The modifications are the same ones.

index.php, around line 92:
$tags = array("uid""writer_id", [color=CC0033]"art_source",[/color"art_title""art_summary""art_image""art_pages""art_categories""art_time_publish""art_counter""art_comments");


index.php, around line 117:
$_article = array(
        
"id"         => $id,
        
"title"        => $articles_obj[$id]->getVar("art_title"),
        
"author"    => @$users[$articles_obj[$id]->getVar("uid")],
        
"writer"    => @$writers[$articles_obj[$id]->getVar("writer_id")],
        
"time"        => $articles_obj[$id]->getTime($xoopsModuleConfig["timeformat"]),
        
"image"        => $articles_obj[$id]->getImage(),
[
color=CC0033]        "source"    => $articles_obj[$id]->getVar("art_source"),[/color]
        
"counter"    => $articles_obj[$id]->getVar("art_counter"),
        
"summary"    => $articles_obj[$id]->getSummary( !empty($xoopsModuleConfig["display_summary"]) )
        );

Shouldn't matter where exactly you drop it within the array. The red lines are the ones you would have to add.

Then, you can modify your template article_inc_category.html and use <{$article.source}> as a smarty variable wherever it suits you, for instance on line 70 of the template you use on your site, behind <{$article.time}>.

Now tested, no guarantees against strange behaviour down the line, don't forget to update the module every time you modify a template.

www.affvu.org

5
patagon
Re: Another article 1.0 question
  • 2007/7/21 21:06

  • patagon

  • Quite a regular

  • Posts: 235

  • Since: 2002/1/8 0


Thanks Tobias (again it works! (http://www.descontrol.org/modules/denuncia/ maybe it could use some design, but it shows)

6
Tobias
Re: Another article 1.0 question
  • 2007/7/21 21:41

  • Tobias

  • Not too shy to talk

  • Posts: 172

  • Since: 2005/9/13


The design, I see on your site, you have firmly under control. That's quite nifty how you've assigned a different background color to the different values.
www.affvu.org

Login

Who's Online

104 user(s) are online (77 user(s) are browsing Support Forums)


Members: 0


Guests: 104


more...

Donat-O-Meter

Stats
Goal: $100.00
Due Date: Apr 30
Gross Amount: $0.00
Net Balance: $0.00
Left to go: $100.00
Make donations with PayPal!

Latest GitHub Commits