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?

SNIPPIT:: Add Reads To Custom Pages

Asked Modified Viewed 2,468 times
C
Craig
C
Craig 14
  • Fusioneer, joined since
  • Contributed 4,462 posts on the community forums.
  • Started 212 threads in the forums
  • Started this discussions
asked
Fusioneer

This was a request on [PHPFusion UK] so I thought I will also post the snippit here since it's useful.


This will add page reads to custom Pages.

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

1 post

H
hervan
H
hervan 10
sorry my english is very bad
  • Member, joined since
  • Contributed 93 posts on the community forums.
  • Started 37 threads in the forums
answered
Member

hi i do not understand can help me edit this right viewpage.php:

<?php
/*-------------------------------------------------------+
| PHPFusion Content Management System
| Copyright (C) 2002 - 2011 Nick Jones
| http://www.php-fusion.co.uk/
+--------------------------------------------------------+
| Filename: viewpage.php
| Author: Nick Jones (Digitanium)
+--------------------------------------------------------+
| This program is released as free software under the
| Affero GPL license. You can redistribute it and/or
| modify it under the terms of this license which you
| can read by viewing the included agpl.txt or online
| at www.gnu.org/licenses/agpl.html. Removal of this
| copyright header is strictly prohibited without
| written permission from the original author(s).
+--------------------------------------------------------*/
require_once "maincore.php";
require_once THEMES."templates/header.php";
require_once INCLUDES."comments_include.php";
require_once INCLUDES."ratings_include.php";
include LOCALE.LOCALESET."custom_pages.php";

if (!isset($_GET['page_id']) || !isnum($_GET['page_id'])) { redirect("index.php"); }
if (!isset($_GET['rowstart']) || !isnum($_GET['rowstart'])) { $_GET['rowstart'] = 0; }

$cp_result = dbquery("SELECT * FROM ".DB_CUSTOM_PAGES." WHERE page_id='".$_GET['page_id']."'");
if (dbrows($cp_result)) {
   $cp_data = dbarray($cp_result);
   add_to_title($locale['global_200'].$cp_data['page_title']);
   echo "<!--custompages-pre-content-->\n";
   opentable($cp_data['page_title']);
   if (checkgroup($cp_data['page_access'])) {
      ob_start();
      eval("?>".stripslashes($cp_data['page_content'])."<?php ");
      $custompage = ob_get_contents();
      ob_end_clean();
      $custompage = preg_split("/<!?--\s*pagebreak\s*-->/i", $custompage);
      $pagecount = count($custompage);
      echo $custompage[$_GET['rowstart']];
   } else {
      echo "<div class='admin-message' style='text-align:center'><br /><img style='border:0px; vertical-align:middle;' src ='".BASEDIR."images/warn.png' alt=''/><br /> ".$locale['400']."<br /><a href='index.php' onclick='javascript:history.back();return false;'>".$locale['403']."</a>\n<br /><br /></div>\n";
   }
   
   
   
} else {
   add_to_title($locale['global_200'].$locale['401']);
   echo "<!--custompages-pre-content-->\n";
   opentable($locale['401']);
   echo "<div style='text-align:center'><br />\n".$locale['402']."\n<br /><br /></div>\n";
}
closetable();
if (isset($pagecount) && $pagecount > 1) {
    echo "<div align='center' style='margin-top:5px;'>\n".makepagenav($_GET['rowstart'], 1, $pagecount, 3, FUSION_SELF."?page_id=".$_GET['page_id']."&amp;")."\n</div>\n";
}
echo "<!--custompages-after-content-->\n";
if (dbrows($cp_result) && checkgroup($cp_data['page_access'])) {
   if ($cp_data['page_allow_comments']) { showcomments("C", DB_CUSTOM_PAGES, "page_id", $_GET['page_id'],FUSION_SELF."?page_id=".$_GET['page_id']); }
   if ($cp_data['page_allow_ratings']) { showratings("C", $_GET['page_id'], FUSION_SELF."?page_id=".$_GET['page_id']); }
}

require_once THEMES."templates/footer.php";
?>

0 replies

Labels

None yet

Statistics

  • Views 0 views
  • Posts 1 post
  • 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
  • Started this discussions
H
H
hervan 10
sorry my english is very bad
  • Member, joined since
  • Contributed 93 posts on the community forums.
  • Started 37 threads in the forums

Notifications

Track thread

You are not receiving notifications from this thread.

Related Questions

Not yet