4images Forum & Community

4images Modifications / Modifikationen => Mods & Plugins (Requests & Discussions) => Topic started by: Vincent on August 16, 2005, 05:37:34 PM

Title: Comment Counter
Post by: Vincent on August 16, 2005, 05:37:34 PM
Hello
i look for the code which say total comment: 18

i would like to add this information to the side navigationbar!

thanks for feedback

vincent
Title: Re: Comment Counter
Post by: TheOracle on August 16, 2005, 07:54:34 PM
You mean this one :

Quote

{image_comments}


?
Title: Re: Comment Counter
Post by: Vincent on August 16, 2005, 07:58:27 PM
{image_comments}
added this {image_comments} what is the result?
i would like to have as result in my case now 18 because i have 18comments!

vincent
Title: Re: Comment Counter
Post by: TheOracle on August 16, 2005, 08:01:13 PM
You'd like to add this starting from the index page right ?
Title: Re: Comment Counter
Post by: Vincent on August 16, 2005, 08:03:06 PM
yes from the index page but also categorie detail page and so one - it stay on the left side in the navig list
Title: Re: Comment Counter
Post by: Vincent on August 16, 2005, 08:04:57 PM
http://www.4homepages.de/forum/index.php?topic=9283.0
the link which V@no gave the code for the lightbox counter in the navig
works only if registerd this MOD

this now requested mod should also work for all guest
Title: Re: Comment Counter
Post by: TheOracle on August 16, 2005, 08:27:39 PM
If the comments has not been populated like the lightbox yet (as I said: If), then - in that case - additional codings from includes/functions.php file would need to be done since, for the lightbox, it uses the lightbox_image_ids on many lightbox actions.
Title: Re: Comment Counter
Post by: mawenzi on August 16, 2005, 10:33:32 PM
hallo vincent,

... also ein Kommentar-Counter in der home.html (bzw. auf allen Hauptseiten) ...
... dann hätte ich dieses für dich ... getestet und funktionstüchtig ...  :wink:

folgendes in die includes/page_header.php vor :
Code: [Select]
?>

einsetzen :
Code: [Select]
//-----------------------------------------------------
//--- Kommentar-Counter ---
//-----------------------------------------------------
  $sql = "SELECT SUM(image_comments) AS sum
          FROM ".IMAGES_TABLE;
  $row = $site_db->query_firstrow($sql);

  $sum = (isset($row['sum'])) ? $row['sum'] : 0;
  $total_comments = $row['sum'];
   
  $site_template->register_vars("total_comments", $total_comments);
  unset($total_comments);

nun kannst du in der home.html (deiner Navigationsbar) bzw. allen html-Hauptseiten folgendes als Counter verwenden :
Code: [Select]
Anzahl der Kommentare : {total_comments}

das sollte es gewesen sein ... ist aber zunächst nur einsprachig ... und ich denke du brauchst es nur in deutsch ...  :wink:
(es werden nun noch Vorschläge mit ... $lang_total_comments ... von :?: kommen ...  :mrgreen: )

mawenzi
Title: Re: Comment Counter
Post by: TheOracle on August 17, 2005, 05:00:06 AM
I already tried coding that one ... does it actually work ?
Title: Re: Comment Counter
Post by: mawenzi on August 17, 2005, 10:21:45 AM
hi TheOracle

it works absolutely perfect ...  :wink:

mawenzi
Title: Re: Comment Counter
Post by: TheOracle on August 17, 2005, 11:38:25 AM
I found my mistake.

I stated :

Quote

$sum = (isset($row['sum'])) ? $row['sum'] : "";


rather than :

Code: [Select]

$sum = (isset($row['sum'])) ? $row['sum'] : 0;


Thanks for posting this. ;)
Title: Re: Comment Counter
Post by: Vincent on August 17, 2005, 11:49:53 PM
i am to stupied - how to add the {total_comments} code into a php file?

Code: [Select]
<tr> 
    <td width="100%" align="center" height="20" background="templates/4dark/bbutton.gif">
<div align="left">
<a style="text-decoration: none" href="soldpubl.php">&gt; Verkaufte Fotos {total_comments}</a>
</div>
    </td>
</TR>

Vincent
Title: Re: Comment Counter
Post by: TheOracle on August 17, 2005, 11:55:54 PM
May I ask why this should be added into PHP files rather than HTML files ?
Title: Re: Comment Counter
Post by: Vincent on August 17, 2005, 11:58:39 PM
because the hole navig list is a php file!  :wink:

i am not the coder just a user - so don't ask me - until know it is just fine working like this

vincent
Title: Re: Comment Counter
Post by: TheOracle on August 18, 2005, 12:04:43 AM
Hum ... to be safe, let's rather do it like this :

Code: [Select]

//-----------------------------------------------------
//--- Kommentar-Counter ---
//-----------------------------------------------------
  $sql = "SELECT SUM(image_comments) AS sum
          FROM ".IMAGES_TABLE;
  $row = $site_db->query_firstrow($sql);

  $sum = (isset($row['sum'])) ? $row['sum'] : 0;
  $total_comments = $row['sum'];
   
  $site_template->register_vars("total_comments", $total_comments);

  $site_template->parse_template("total_comments_page");

  unset($total_comments);


Then, create a file called : total_comments_page.html in your templates/<your_template> folder and paste your posted HTML content in that file.

Should work from there. ;)
Title: Re: Comment Counter
Post by: mawenzi on August 18, 2005, 11:43:13 AM
hallo Vincent,

deine Navigationsliste ist eine html-Datei ... aber mit php-Extension ...  :? ... sicher um sie "includen" zu können ...
dann versuche den Kommentrar-Counter in der Navigationsliste mal so zu integrieren ...
Code: [Select]
...
<a style="text-decoration: none" href="soldpubl.php">&gt; Verkaufte Fotos <? print $total_comments ?></a>
...

mawenzi
Title: Re: Comment Counter
Post by: TheOracle on August 18, 2005, 12:07:49 PM
Quote

<a style="text-decoration: none" href="soldpubl.php">&gt; Verkaufte Fotos <? print $total_comments ?></a>


This method would not be advisable since your URL is not being used under sessions.

Althought, what you could do is this (if you intend to use it under PHP) :

Code: [Select]

<a style=\"yourCSSfile(rather than the code directly here)\" href=\"".$site_sess->url(ROOT_PATH."soldpubl.php")."\">&gt; Verkaufte Fotos ".$total_comments."</a>


;)
Title: Re: Comment Counter
Post by: mawenzi on August 18, 2005, 05:33:51 PM
@ TheOracle,
... mmm ... your solution don't work in html-files renamed as php-files ... like in templates by vierstra ...  :?

@ Vincent,
folgendes habe ich für deine verzwickte Situation (Template by vierstra.com) getestet ...

1. den Kommentar-Counter hast du wie bereits beschrieben in der page_header.php eingebaut

2. in allen Template-Seiten in denen du diesen Counter in deiner Navigationsleiste zeigen willst , also home.html, usw. ... , fügst du unmittelbar unter {header} folgendes ein :
Code: [Select]
<?php
 $tc 
"{total_comments}";
?>


3. nun kannst du in deiner menue.php (bzw. wie deine Navigationsliste heist) folgendes für die Anzahl der Kommentare (bei dir, die der verkauften Bilder) verwenden ( <? print $tc ?> ). Dein Link im Menü würde dann so aussehen :
Code: [Select]
<a style="text-decoration: none" href="soldpubl.php">&gt; Verkaufte Fotos <? print $tc ?></a>
soweit funktioniert es zunächst nach dem Prinzip von vierstra !

4. Die Verwendung deiner Links in der Navigationliste unter "sessionsid" (wie von TheOracle angeregt) solltest du dann anschließend noch prüfen ! Wobei ich den Link mit sess-id in der page_header.php registrieren würde.
Code: [Select]
"url_soldpubl" => $site_sess->url(ROOT_PATH."soldpubl.php"),
so dass du als URL für den Link in der menue.php (bzw. wie deine Navigationsliste heist) folgendes verwenden kannst : {soldpubl}

mawenzi
Title: Re: Comment Counter
Post by: Vincent on August 18, 2005, 07:46:48 PM
@Mawenzi
VIELEN DANK  für die Hilfe - es geht - hab es aber doch ein bisschen anders gemacht!

statt es (<?php $tc = "{total_comments}"; ?>) in jeder HTML Datei unter {header} einzufügen habe ich es in der header.html datei am schluss eingefügt!

Danach musste ich nur noch <? print $tc ?> nach dem verkaufte Fotos text eingeben! und es funzt so wie ich es mir wünschte !

nochmals vielen Dank!  :wink:

vincent
Title: Re: Comment Counter
Post by: mawenzi on August 18, 2005, 09:41:48 PM
... habe ich es in der header.html datei am schluss eingefügt!

... hast natürlich Recht ... hatte es nur auf einer Seite getestet und von daher mein voreiliger Schluss ...  :lol:
freut mich, dass es nun endlich geklappt hat ...

mawenzi
Title: Re: Comment Counter
Post by: TheOracle on August 20, 2005, 02:24:15 PM
Quote

@ TheOracle,
... mmm ... your solution don't work in html-files renamed as php-files ... like in templates by vierstra ...  Confused


My solution was never about renaming HTML files as PHP files but parsing PHP initials into HTML files.  :?