1
turnerrw
TinyContent Addition
  • 2004/1/9 3:52

  • turnerrw

  • Just popping in

  • Posts: 68

  • Since: 2003/12/1


Does anyone know how I could add a counter to TinyContent? I like the News feature that counts the number of times a story is read and would like the same feature in TinyContent.


2
chapi
Re: TinyContent Addition
  • 2004/1/9 8:10

  • chapi

  • Theme Designer

  • Posts: 611

  • Since: 2002/1/22


You have to add a new field to the database. Maybe you call it "counter". Additionaly you have to edit the index.php in the module folder of TinyContent. Everytime a content is selected out of the database you have to increment this counter value.

After that you can assign the value of this counter to the template and show it through the template on your site!

3
JimLinch
Re: TinyContent Addition
  • 2004/1/9 10:47

  • JimLinch

  • Just popping in

  • Posts: 11

  • Since: 2004/1/7 9


I wanted this also, and got the counter working, but can't figure out why I'm not passing it to the blocktemplate.

I added:
while($tcontent $xoopsDB->fetchArray($result)) {
          
$link = array();
          
$link['id'] = $tcontent['storyid'];
          
$link['title'] = $myts->makeTboxData4Show($tcontent['title']);
          [
color=000099]$link['counter'] = $tcontent['counter'];[/color]
          
$block['links'][] = $link;
        }
        return 
$block;
to the tc_navigation.php file, and changed the /blocks/tc_nav_block.html in the DB like so...
<table cellspacing="0">
  <
tr>
    <
td id="mainmenu">
  <{foreach 
item=link from=$block.links}>
    <
class="menuMain" href="<{$xoops_url}>/modules/tinycontent/index.php?id=<{$link.id}>"><{$link.title}>a>[color=000099](<{$link.counter}>)[/color]
  <{/foreach}>
    td>
  tr>
table>
but can not write the value into the template.

I know $link['counter'] is getting populated because I switched <{$link.id}> with <{$link.counter}> in the template and the URL links displayed the number of counts for each article, but whenever I try to send 3 items to the template it's no go.

Any ideas as to what I'm doing wrong here?

4
chapi
Re: TinyContent Addition
  • 2004/1/9 11:33

  • chapi

  • Theme Designer

  • Posts: 611

  • Since: 2002/1/22


Did you also change the sql query from ..

$result $xoopsDB->query("SELECT storyid, blockid, title, visible FROM ".


to something like this ?

$result $xoopsDB->query("SELECT storyid, blockid, title, visible, counter FROM ".

5
JimLinch
Re: TinyContent Addition
  • 2004/1/10 4:58

  • JimLinch

  • Just popping in

  • Posts: 11

  • Since: 2004/1/7 9


Yes. Sorry i forgot to post that.

$result $xoopsDB->query("SELECT storyid, blockid, title, visible, counter FROM ".$xoopsDB->prefix('tinycontent')." WHERE visible='1' ORDER BY storyid DESC");

6
JimLinch
Re: TinyContent Addition
  • 2004/1/13 14:45

  • JimLinch

  • Just popping in

  • Posts: 11

  • Since: 2004/1/7 9


Sorry, it does work. I forgot to clear templates_c

Login

Who's Online

842 user(s) are online (84 user(s) are browsing Support Forums)


Members: 0


Guests: 842


more...

Donat-O-Meter

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

Latest GitHub Commits