MX Kollection Forum :: Adding a View Counter to Blog Article

This thread was displayed: 86 times


Starting with 17th May 2007, Adobe Systems will stop offering support for any version of the discontinued InterAKT products. As a result, we will not answer to new support incidents starting with May 17th, 2007. Pending support incidents will still be followed in order to be closed. The product forums will remain open and be transformed in user-to-user forums. The general forums will be made read-only and not allow new posts or comments.

For more information about the affected products visit: www.interaktonline.com/Support/

View Threaded Show descending
Brad LawrykTeam InterAKT member
10-28-2005 21:50:22 GMT +2

 

Okay, starting a new thread on  this one ;-)

I added a counter to my articles on the blog that I built using the Blog Article on this site. This will add a counter to display how many times an article has been viewed. Of coourse you can also get some handy stats like most and least viewed articles as well out of this.

1: Add a new field to the blg_article_art table and call it count_art. Set this field to int, length 11 and set 0 as the default. If adding this to a populated table you will have to run an SQL Query (UPDATE blg_article_art SET count_art = 0) to fill the column with 0 as the counter will not work if there is no digit in the column.

2: On the page that displays the article (article.php) you need to add a custom transaction. In the Custom Transaction UI under the Basic Tab, set your connection of course, then in the First Check Variable set that to Entered Value and 1. Leave the redirect empty. Also ignore the Fields Tab.

3: Then on the Advanced Tab, you can give your transaction a name if you like as it must be unique. I call mine countup. Then in the SQL Query text area enter:

UPDATE blg_article_art SET count_art = count_art+1 WHERE id_art={GET.id_art}

Note: This uses the table and field names from the Blog Article Tutorial. Your table and field names may vary.

4: Save and Upload Page.

5: Now on the same page, you can now display the count total by simply adding from the bindings panel the value of count_art anywhere on your page you want to display it.

6: Save and Upload ..... view page in browser and refresh a few times to see the counter go up.

Enjoy. This will also work for any record that you want to show how many times its been viewed in almost any database dynamic page situation.

Brad
Back | Reply | Quote | Top
Marius ZAHARIA[InterAKT]Adobe Systems Romania staff
10-31-2005 09:15:15 GMT +2

Thanks, Brad!

Sounds like a great idea for another HOW-TO! ;)

We'll throw in some screenshots, too. But don't expect this published too soon - we're working hard on KTML right now.

Regards,

Marius

Reply | Quote | Top
Brad LawrykTeam InterAKT member
10-31-2005 17:32:03 GMT +2

 

Haha, I don't expect it to ever be published, its not a nobel peace prize tip. lol.

Just thought some people may be interested.

Another idea is to add a timestamp coumn to the articles table and you can also display or keep track of the last time an article was viewed.

Brad
Reply | Quote | Top
David Ramirez
10-18-2006 20:16:18 GMT +2

wow... I was searching for this since the last year... thanks!
Every day I learn new tricks :)

Reply | Quote | Top
Zulians
04-11-2007 23:20:37 GMT +2



Hello

I have tried that, but nothing happend? here is the code, I wanted to update TimesViewed field everytime when someone coming from news.php to the newsdetail.php, I did this in newsdetail.php so, whenever someone come to news details, 1 must be added.


// Make a custom transaction instance
$countview = new tNG_custom($conn_connDra);
$tNGs->addTransaction($countview);
// Register triggers
$countview->registerTrigger("STARTER", "Trigger_Default_Starter", 1, "VALUE", "1");
// Set custom transaction SQL
$countview->setSQL("UPDATE vom_dhinews SET TimesViewed = TimesViewed+ 1 WHERE NewsID={GET.NewsID}");
// Add columns
// End of custom transaction instance

// Execute all the registered transactions
$tNGs->executeTransactions();

// Get the transaction recordset
$rscustom = $tNGs->getRecordset("custom");
$row_rscustom = mysql_fetch_assoc($rscustom);
$totalRows_rscustom = mysql_num_rows($rscustom);


Thanks
 

Reply | Quote | Top
David Ramirez
04-12-2007 19:41:33 GMT +2

Hello...

When I do this, my code looks like this:

// Make a custom transaction instance
$customTransaction = new tNG_custom($conn_connEvenpro);
$tNGs->addTransaction($customTransaction);
// Register triggers
$customTransaction->registerTrigger("STARTER", "Trigger_Default_Starter", 1, "VALUE", "1");
// Set custom transaction SQL
$customTransaction->setSQL("UPDATE evp_noticias SET not_counter = not_counter+1 WHERE noticia_id={GET.noticia_id}");
// Add columns
// End of custom transaction instance

Tell me how are you creating the custom transaction.

Keep in touch, I will help you.

Reply | Quote | Top
Zulians
04-12-2007 22:43:47 GMT +2

Hello Sir,

I am doing it same as what Brad has explained at the top post... 

Thank you

Reply | Quote | Top
David Ramirez
04-12-2007 22:54:48 GMT +2

Hello...


Tell me what version of Interakt are using... I dont understand why your code looks different of mine.

Remember: dont create the custom transaction from the insert bar, go to Server Behaviors > MX Kollection > Forms > Advanced > Custom Transaction.

  1. Select your connection.
  2. First Check Variable: Entered Value = 1
  3. Fields Tab: Do Nothing
  4. Advanced Tab: Paste this SQL and edit with your table and fields names:

UPDATE blg_article_art SET count_art = count_art+1 WHERE id_art={GET.id_art}

That's all. Write a line if you still have problems.

Bye, takc care....

Reply | Quote | Top
Zulians
04-12-2007 23:35:18 GMT +2

Hello Sir,

I am using Kollection Pro 3.7.1

Doing exaclty same .......?????


Thanks

Reply | Quote | Top
Zulians
04-13-2007 00:11:33 GMT +2

Hello 

I found this is more easier than everything..

mysql_select_db($database_connTest, $connTest);
$query_rsTimewsViewed = "UPDATE vom_dhinews SET TimesViewed = TimesViewed+ 1 WHERE NewsID='$NewsID'";
$rsTimewsViewed = mysql_query($query_rsTimewsViewed, $connTest) or die(mysql_error());

this code is working with less complication.

Thanks

Reply | Quote | Top
© Adobe Systems Romania. All rights reserved.