Oh no! Where's the JavaScript?
Your Web browser does not have JavaScript enabled or does not support JavaScript. Please enable JavaScript on your Web browser to properly view this Web site, or upgrade to a Web browser that does support JavaScript.
Not a member yet? Click here to register.
Forgot Password?

"Reads" in custom pages?

Asked Modified Viewed 4,494 times
P
Pippi
P
Pippi 10
  • Member, joined since
  • Contributed 65 posts on the community forums.
  • Started 13 threads in the forums
  • Started this discussions
asked
Member

Hi
Is it possible to add "Reads" to custom pages?
With "Reads" I mean like in news, when you can se how many "Reads" the news have.
Could I have a counter like that in the bottom of each custom page i create?
0 replies

13 posts

C
Craig
C
Craig 14
  • Fusioneer, joined since
  • Contributed 4,462 posts on the community forums.
  • Started 212 threads in the forums
answered
Fusioneer

Sure ok.

First we will add a column to the DB_CUSTOM_PAGES so go to Admin >>> content >>> Custom Pages and preview this...

<?php
$result = dbquery("ALTER TABLE ".DB_CUSTOM_PAGES." ADD page_count INT(10) UNSIGNED NOT NULL DEFAULT '0' AFTER page_allow_ratings ");
?>


OK that is the DB_CUSTOM_PAGES table altered. We added page_count after page_allow_ratings


Next, Edit viewpage.php

Look for around line 47...

opentable($locale['401']);
   echo "<div style='text-align:center'><br />\n".$locale['402']."\n<br /><br /></div>\n";
}


After that paste this...

if (isset($_GET['page_id']) || isnum($_GET['page_id'])) {
$result = dbquery("UPDATE ".DB_CUSTOM_PAGES." SET page_count=page_count+1 WHERE page_id='".$_GET['page_id']."'");
}
echo"<br /><div style='text-align:right;' class='small'>Reads: ".$cp_data['page_count']."</div>\n";


Save, upload, Overwrite.

Now your custom pages has a reads counter.
0 replies
P
Pippi
P
Pippi 10
  • Member, joined since
  • Contributed 65 posts on the community forums.
  • Started 13 threads in the forums
  • Started this discussions
answered
Member

I can't find this:
First we will add a column to the DB_CUSTOM_PAGES so go to Admin >>> content >>> Custom Pages and preview this..
Where shall I look? In the files (ftp)? In the DB?
0 replies
C
Craig
C
Craig 14
  • Fusioneer, joined since
  • Contributed 4,462 posts on the community forums.
  • Started 212 threads in the forums
answered
Fusioneer

Your Site >>> Site Admin >>> content >>> Custom Pages
0 replies
P
Pippi
P
Pippi 10
  • Member, joined since
  • Contributed 65 posts on the community forums.
  • Started 13 threads in the forums
  • Started this discussions
answered
Member

How do I Preview? In Tiny MCE?
0 replies
C
Craig
C
Craig 14
  • Fusioneer, joined since
  • Contributed 4,462 posts on the community forums.
  • Started 212 threads in the forums
answered
Fusioneer

Disable TinyMCE for this.

Then just press "Preview Page"
0 replies
P
Pippi
P
Pippi 10
  • Member, joined since
  • Contributed 65 posts on the community forums.
  • Started 13 threads in the forums
  • Started this discussions
answered
Member

Ok, I feel a little stupid here now.
I disabled Tiny MCE, when i press "Preview page" I'm asked to write a headline, I do, then write admin password, and then nothing but the headline shows?
Shall I write this code in TinyMCE?
0 replies
C
Craig
C
Craig 14
  • Fusioneer, joined since
  • Contributed 4,462 posts on the community forums.
  • Started 212 threads in the forums
answered
Fusioneer

No nothing will happen it will just insert a column in your custom pages db. Now do the next stage of what I wrote above.
0 replies
P
Pippi
P
Pippi 10
  • Member, joined since
  • Contributed 65 posts on the community forums.
  • Started 13 threads in the forums
  • Started this discussions
answered
Member

Ok, I was looking for that code. ;)

So I went on, an something is wrong, Unknown column 'page_count' in 'field list', look in the bottom of the page: http://lindbergduene.no/viewpage.php?...page_id=37

   opentable($locale['401']);
   echo "<div style='text-align:center'><br />\n".$locale['402']."\n<br /><br /></div>\n";
}
if (isset($_GET['page_id']) || isnum($_GET['page_id'])) {
$result = dbquery("UPDATE ".DB_CUSTOM_PAGES." SET page_count=page_count+1 WHERE page_id='".$_GET['page_id']."'");
}
echo"<br /><div style='text-align:right;' class='small'>Reads: ".$cp_data['page_count']."</div>\n";
0 replies
C
Craig
C
Craig 14
  • Fusioneer, joined since
  • Contributed 4,462 posts on the community forums.
  • Started 212 threads in the forums
answered
Fusioneer

You need to preview the code again in custom pages preview....

Page title: Bleh

<?php
$result = dbquery("ALTER TABLE ".DB_CUSTOM_PAGES." ADD page_count INT(10) UNSIGNED NOT NULL DEFAULT '0' AFTER page_allow_ratings ");
?>



Preview
0 replies
P
Pippi
P
Pippi 10
  • Member, joined since
  • Contributed 65 posts on the community forums.
  • Started 13 threads in the forums
  • Started this discussions
answered
Member

Thank you so much for your help, now I got it.:D
0 replies
C
Craig
C
Craig 14
  • Fusioneer, joined since
  • Contributed 4,462 posts on the community forums.
  • Started 212 threads in the forums
answered
Fusioneer

Is it working for you? Can I see?
0 replies
P
Pippi
P
Pippi 10
  • Member, joined since
  • Contributed 65 posts on the community forums.
  • Started 13 threads in the forums
  • Started this discussions
answered
Member

C
Craig
C
Craig 14
  • Fusioneer, joined since
  • Contributed 4,462 posts on the community forums.
  • Started 212 threads in the forums
answered
Fusioneer

Great. :)
0 replies

Labels

None yet

Statistics

  • Views 0 views
  • Posts 13 posts
  • Votes 0 votes
  • Topic users 2 members

2 participants

C
C
Craig 14
  • Fusioneer, joined since
  • Contributed 4,462 posts on the community forums.
  • Started 212 threads in the forums
P
P
Pippi 10
  • Member, joined since
  • Contributed 65 posts on the community forums.
  • Started 13 threads in the forums
  • Started this discussions

Notifications

Track thread

You are not receiving notifications from this thread.

Related Questions

Not yet