>>  Site Map >>  Forums >>  Modules 6x

Forum module - topics in forum:



Modules 6x - Discussions regarding PHP-Nuke Modules.



Adding extra options to review page

Hi

I'm trying to make a slight modification for myself, but I've never coded PHP before so my knowledge is extremely limited. What I'm trying to do is to add another text box in the write_reviews thingy, and then make make a perfectly functionable new... thing (crap, don't know what it's called, you know, like: $thing). I constructed it kind of like the $url thing, because I will use my $ in a link (<a href="$url2"><img src="pic.gif"></a>).

I've managed to make a new textbox and get everything working, exept one little (well... pretty big) detail. It doesn't work when you're viewing the review. The link isn't the one you entered in the text box when you wrote the review, it's just a link to the page same page that you are viewing. It works good when you preview the review, but when you view the review it's doesn't. And no, it's not that I haven't changed that the link I'm trying to make should appear in the review, the link appears, but the url is wrong.

What's the problem? I can say that I've only made changes to the modules/reviews/index.php file, and what I did was to search for "url", and make similar enteries below the the already existing one, where I changed "url" to "url2".

Thanks in advance,
n0thing






The preview and live versions of the review are two seperate pieces of code. So it could be something as simple as forgetting to change a variable (Thats what the $things are called by the way Wink ) in the live section of the review code.






Cypher_489 Wrote: :
The preview and live versions of the review are two seperate pieces of code. So it could be something as simple as forgetting to change a variable (Thats what the $things are called by the way Wink ) in the live section of the review code.


Thanks for answering!

Well, I looked through the showcontent (that's the "live version" of the review, right?) and only found one thing I didn't change, but it didn't really look necessary and that's the " if (!empty($url))" part, just above the Related Link. I figured that it only meant that if the $url field was empty when you wrote the review, it would show... something else. Yeah, well. Keep in mind that I'm trying to add another variable (thanks Smile ), not changing an already existing one so I just thought it wasn't important. However, I could post my showcontent-code below, so if you have some spare time to look through it I'd appreciate it. Is there anything I have to change?

Code: :
function showcontent($id, $page, $cdonurl) {
   global $admin, $uimages, $prefix, $db, $module_name;
   $id = intval($id);
   $page = intval($page);
   include ('header.php');
   OpenTable();
   if (($page == 1) OR (empty($page))) {
      $db->sql_query("UPDATE ".$prefix."_reviews SET hits=hits+1 WHERE id='$id'");
   }
   $result = $db->sql_query("SELECT * FROM ".$prefix."_reviews WHERE id='$id'");
   $myrow = $db->sql_fetchrow($result);
   $id = intval($myrow['id']);
   $date = $myrow['date'];
   $year = substr($date,0,4);
   $month = substr($date,5,2);
   $day = substr($date,8,2);
   $fdate = date("F jS Y",mktime (0,0,0,$month,$day,$year));
   $title = $myrow['title'];
   $title = stripslashes(FixQuotes(check_html($title, "nohtml")));
   $text = $myrow['text'];
   $cover = $myrow['cover'];
   $reviewer = $myrow['reviewer'];
   $email = $myrow['email'];
   $hits = intval($myrow['hits']);
   $url = $myrow['url'];
   $url_title = $myrow['url_title'];
   $cdonurl = $myrow['cdonurl'];
   $score = intval($myrow['score']);
   $contentpages = explode( "<!--pagebreak-->", $text );
   $pageno = count($contentpages);
   if ( $page=="" || $page < 1 )
   $page = 1;
   if ( $page > $pageno )
   $page = $pageno;
   $arrayelement = (int)$page;
   $arrayelement --;
   echo "<p><i><b><font class=\"title\">$title</b></i></font><br>";
   echo "<BLOCKQUOTE><p align=justify>";
   if (!empty($cover))
   echo "<table align=right border=0 cellspacing=5 cellpadding=0><tr><td bgcolor=#000000><table border=0 cellspacing=0 cellpadding=0><tr><td bgcolor=#FFFFFF align=center><img src=images/reviews/$cover></td></tr><tr>
        <td bgcolor=#FFFFFF align=center><table align=center border=0 cellspacing=5 cellpadding=0><tr><td bgcolor=#000000><table border=0 cellspacing=1 cellpadding=1 width=240><tr><td bgcolor=#FFFFFF align=center><font size=1>Köp skivan på:<br><a href=\"$cdonurl\"><img STYLE=\"border: 0px none\" src=http://test.swegeeks.com/images/cdon2.gif></a>&nbsp;&nbsp;<img src=http://test.swegeeks.com/images/cdon2.gif>&nbsp;&nbsp;<img src=http://test.swegeeks.com/images/cdon2.gif>&nbsp;&nbsp;<img src=http://test.swegeeks.com/images/cdon2.gif></font></td></tr></table></td></tr></table></td></tr></table></td></tr></table>";
   echo "<br>$contentpages[$arrayelement]
    </BLOCKQUOTE><p>";
   if (is_admin($admin))
   echo "<b>"._ADMIN."</b> [ <a href=\"modules.php?name=$module_name&rop=mod_review&amp;id=$id\">"._EDIT."</a> | <a href=modules.php?name=$module_name&rop=del_review&amp;id_del=$id>"._DELETE."</a> ]<br>";
   echo "<b>"._ADDED."</b> $fdate<br>";
   if (!empty($reviewer))
   echo "<b>"._REVIEWER."</b> <a href=mailto:$email>$reviewer</a><br>";
   if (!empty($score))
   echo "<b>"._SCORE."</b> ";
   display_score($score);
   if (!empty($url))
   echo "<br><b>"._RELATEDLINK.":</b> <a href=\"$url\" target=new>$url_title</a>";
   echo "<br><b>"._HITS.":</b> $hits";
   if ($pageno > 1) {
      echo "<br><b>"._PAGE.":</b> $page/$pageno<br>";
   }
   echo "</font>";
   echo "</CENTER>";
   $title = urlencode($title);
   if($page >= $pageno) {
      $next_page = "";
   } else {
      $next_pagenumber = $page + 1;
      if ($page != 1) {
         $next_page .= "<img src=\"images/blackpixel.gif\" width=\"10\" height=\"2\" border=\"0\" alt=\"\"> &nbsp;&nbsp; ";
      }
      $next_page .= "<a href=\"modules.php?name=$module_name&rop=showcontent&amp;id=$id&amp;page=$next_pagenumber\">"._NEXT." ($next_pagenumber/$pageno)</a> <a href=\"modules.php?name=$module_name&rop=showcontent&amp;id=$id&amp;page=$next_pagenumber\"><img src=\"images/right.gif\" border=\"0\" alt=\""._NEXT."\"></a>";
   }
   if($page <= 1) {
      $previous_page = "";
   } else {
      $previous_pagenumber = $page - 1;
      $previous_page = "<a href=\"modules.php?name=$module_name&rop=showcontent&amp;id=$id&amp;page=$previous_pagenumber\"><img src=\"images/left.gif\" border=\"0\" alt=\""._PREVIOUS."\"></a> <a href=\"modules.php?name=$module_name&rop=showcontent&amp;id=$id&amp;page=$previous_pagenumber\">"._PREVIOUS." ($previous_pagenumber/$pageno)</a>";
   }
   echo "<center>"
   ."$previous_page &nbsp;&nbsp; $next_page<br><br>"
   ."[ <a href=\"modules.php?name=$module_name\">"._RBACK."</a> | "
   ."<a href=\"modules.php?name=$module_name&rop=postcomment&amp;id=$id&amp;title=$title\">"._REPLYMAIN."</a> ]";
   CloseTable();
   if (($page == 1) OR (empty($page))) {
      echo "<br>";
      r_comments($id, $title);
   }
   include ("footer.php");
}


Edit: Oh, yeah, the variable I tried to add is called $cdonurl. It's in the cover image section - I added a table below it, and in it I put a picture linking to the url entered when you wrote the review ($cdonurl). I know it's a lot of tables, but I didn't have the time to check out how you could make it look like I wanted in CSS, so I just made a lot of tables and experimented.






I haven't had a proper look at the code you gave but "if (!empty($url))" actually means if it is NOT empty, do this... An ! sign before something means "not".

What I think you might have done is placed the code you wanted in the section that is if it IS empty. Try moving it to the if is not empty part.






Cypher_489 Wrote: :
I haven't had a proper look at the code you gave but "if (!empty($url))" actually means if it is NOT empty, do this... An ! sign before something means "not".

What I think you might have done is placed the code you wanted in the section that is if it IS empty. Try moving it to the if is not empty part.


Okay, I think I understand. "if (!empty($url))" means that if it says:
"if (!empty($url))
echo "hello";

it displays the text "hello" if the $url box was filled out? What if it wasn't, I guess it doesn't display anything then?

Well, I could cut out the part that involves the $cdonurl variable I created:

Code: :
   if (!empty($cover))
   echo "<a href=\"$cdonurl\"><img STYLE=\"border: 0px none\" src=http://test.swegeeks.com/images/cdon2.gif></a>";


There's actually a lot more in there, in the echo ".." part, but since it shouldn't affect anything, I cut it out and left the part that actually involved the variable. What you see above says that, if you've choosen a cover image when writing the review, it shows the code that is written under? I guess it should work then, or am I wrong? Well, if you get some time over to look at my code above, please do. I don't know what to do anymore, it feels like I've tried everything. Sad




Attention! You are currently viewing sitemap page!
We strongly suggest to look at original content

Search from web

Valid HTML 4.01 Valid CSS