Author Topic: Entry Count request not problem  (Read 3608 times)

0 Members and 1 Guest are viewing this topic.

Offline scorpio4646

Re: Entry Count request not problem
« Reply #10 on: 30. June 2009, 11:36:13 »
am I posting in wrong forum as I always have to wait several days for a response
Country: Spain Spain |  OS: Unknown Unknown Browser: Unknown Unknown | View Profile

Offline scorpio4646

Re: Entry Count request not problem
« Reply #11 on: 30. June 2009, 12:18:21 »
I have searched forum and found the following piece of code

<?php
   $count_sql = 'SELECT COUNT(*) FROM jos_sobi2_item WHERE `published` = 1';
   $count_result = mysql_query($count_sql);
   $count = mysql_fetch_row($count_result);
   $totalcount = $count[0];

    echo "Total Listings: ".$totalcount;
?>

the problem is where to put it so that it shows, no rude answers please
Country: Spain Spain |  OS: Unknown Unknown Browser: Unknown Unknown | View Profile

Do you want continued ongoing development, new features and active support?
Please write a review or just vote for SOBI on JED.

Offline Poffen

  • SOBI Team
  • Moderator
  • Sobi Hero
  • *
  • Posts: 2296
  • Reviews:

    What is it?

Re: Entry Count request not problem
« Reply #12 on: 30. June 2009, 20:39:37 »
Hi scorpio4646,

If you're going to show the total number of entries by making a query, it's better I think to use the appropriate joomla code to make the query, and perhaps enclose the ouput in a h tag or something.

You could try something like this:

<?php
$db 
=& JFactory::getDBO();
$query 'SELECT COUNT(*) FROM `#__sobi2_item` WHERE published = 1';
$db->setQuery$query );
$count $db->loadResult();
echo 
"<h3>Total Listings: ".$count."</h3>";
?>


Quote
the problem is where to put it so that it shows, no rude answers please

It depends on where you want to display it, of course. If you put it on the very top of the details view template, it will show up above the listing. I would not recommend putting it into the vcard, as I think it will repeat itself.

If you want to put it on any of the Sobi2 front pages, you will have to hack the core files. Unless you know exactly what you are doing, I would not recommend this either.

However, a much better solution, I think, is to use this third party module: http://extensions.joomla.org/extensions/extension-specific/sobi2-extensions/5364/details This module gives you exactly what you want and can also be configured to display additional information like number of listings entered today, last week and last month. Then you can display the data anywhere you want.


Regards Poffen
« Last Edit: 30. June 2009, 21:35:13 by Poffen »
Joomla - 1.5.7, Sobi2 - 2.9.0.1
PHP - 5.2.4, MySQL - 5.0.51a, Apache - 2.2.8, Firefox - 3.0.3
Country: Norway Norway |  OS: Unknown Unknown Browser: Unknown Unknown | View Profile

Offline scorpio4646

Re: Entry Count request not problem
« Reply #13 on: 03. July 2009, 16:06:57 »
I tried putting the code in the detail view template and it didnt show at all. I am putting it in
sobi2.details.tmpl.php
is this correct?
Country: Spain Spain |  OS: Unknown Unknown Browser: Unknown Unknown | View Profile

Offline Poffen

  • SOBI Team
  • Moderator
  • Sobi Hero
  • *
  • Posts: 2296
  • Reviews:

    What is it?

Re: Entry Count request not problem
« Reply #14 on: 04. July 2009, 21:41:32 »
Hi again,

I tried putting the code in the detail view template and it didnt show at all. I am putting it in
sobi2.details.tmpl.php
is this correct?

Yes, that's what I meant. I just tried the code, and it worked ok for me. Could you post the template code here?

Poffen
Joomla - 1.5.7, Sobi2 - 2.9.0.1
PHP - 5.2.4, MySQL - 5.0.51a, Apache - 2.2.8, Firefox - 3.0.3
Country: Norway Norway |  OS: Unknown Unknown Browser: Unknown Unknown | View Profile

Offline Syrinx

Re: Entry Count request not problem
« Reply #15 on: 04. July 2009, 22:06:33 »
am I posting in wrong forum as I always have to wait several days for a response

No, you are posting in the right forum. Everyone is a volunteer here and we all have lives, so there is no guarantee or promise that your questions will be answered within a certain amount of time. And some questions simply will not have an answer.
Country: United States United States |  OS: Unknown Unknown Browser: Unknown Unknown | View Profile

Offline scorpio4646

Re: Entry Count request not problem
« Reply #16 on: 04. July 2009, 23:30:17 »
ok here it is. I had to post it as a text file
Country: Spain Spain |  OS: Unknown Unknown Browser: Unknown Unknown | View Profile

Offline Poffen

  • SOBI Team
  • Moderator
  • Sobi Hero
  • *
  • Posts: 2296
  • Reviews:

    What is it?

Re: Entry Count request not problem
« Reply #17 on: 04. July 2009, 23:50:03 »
You could try to insert the code as shown below after the php end tag following "This is the template..." and before the "<?php HTML_SOBI...":

Code: [Select]
/* ------------------------------------------------------------------------------
 * This is the template for the Details View
 * ------------------------------------------------------------------------------
 */
?>


<!-- Insert to display the number of published entries -->

<?php
$db 
=& JFactory::getDBO();
$query 'SELECT COUNT(*) FROM `#__sobi2_item` WHERE published = 1';
$db->setQuery$query );
$count $db->loadResult();
echo 
"<h3>Total Listings: ".(int) $count."</h3>";
?>


<!-- End of insert -->

<?php HTML_SOBI::renewal$config,$mySobi ); ?>

If you copy and paste, make sure there are no "&nbsp;" in the code (this happens quite frequently). This will destroy the code.


Poffen
Joomla - 1.5.7, Sobi2 - 2.9.0.1
PHP - 5.2.4, MySQL - 5.0.51a, Apache - 2.2.8, Firefox - 3.0.3
Country: Norway Norway |  OS: Unknown Unknown Browser: Unknown Unknown | View Profile

Offline scorpio4646

Re: Entry Count request not problem
« Reply #18 on: 05. July 2009, 13:42:15 »
well thanks for the time and help but just cannot get this to show
here is the complete php file as I've modified it. Bit of a long post, sorry
. Hope you can sort this for me


<?php
/**
* @version $Id: sobi2.details.tmpl.php 4820 2009-01-05 11:46:25Z Radek Suski $
* @package: Sigsiu Online Business Index 2
* ===================================================
* @author
* Name: Sigrid & Radek Suski, Sigsiu.NET
* Email: sobi@sigsiu.net
* Url: http://www.sigsiu.net
* ===================================================
* @copyright Copyright (C) 2006 - 2009 Sigsiu.NET (http://www.sigsiu.net). All rights reserved.
* @license see http://www.gnu.org/licenses/old-licenses/gpl-2.0.html GNU/GPL.
* You can use, redistribute this file and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation.
*/

/*please do not remove this line */
defined( '_SOBI2_' ) || ( trigger_error("Restricted access", E_USER_ERROR) && exit() );

/* ------------------------------------------------------------------------------
 * This is the template for the Details View
 * ------------------------------------------------------------------------------
 */
?>
<!-- Insert to display the number of published entries -->

<?php
$db =& JFactory::getDBO();
$query = 'SELECT COUNT(*) FROM `#__sobi2_item` WHERE published = 1';
$db->setQuery( $query );
$count = $db->loadResult();
echo "<h3>Total Listings: ".(int) $count."</h3>";
?>

<!-- End of insert -->

<?php HTML_SOBI::renewal( $config,$mySobi ); ?>
<table class="sobi2Details" <?php echo $style; ?> >
   <tr>
      <td><?php echo $ico; ?><h1><?php echo $mySobi->title; ?></h1></td>
   </tr>
   <tr>
      <td><?php echo $img; ?></td>
   </tr>
   <tr>
      <td><?php HTML_SOBI::showGoogleMaps($mySobi, $config); ?></td>
   </tr>
   <tr>
      <td>
         <div id="sobi2outer">
             <?php HTML_SOBI::waySearchUrl( $waySearchLink,$config ); ?>
             <?php echo HTML_SOBI::customFieldsData( $fieldsFormatted );?>
            <br />
         </div>
      </td>
   </tr>
</table>
<table class="sobi2DetailsFooter" width="100%">
   <tr>
     <td>
      <?php HTML_SOBI::addedDate($config,$mySobi); ?>
         &nbsp;&nbsp;
      <?php HTML_SOBI::showHits($config,$mySobi);?>
     </td>
     <td><?php HTML_SOBI::editButtons($config,$mySobi); ?></td>
     
 
 
</table>

  </tr>
</table>
<br />
<table width="849" border="0">
  <tr>
    <th width="839" scope="col"><div align="center"><strong>Please mention RadioQFM Business Directory
    when responding to our adverts!</strong></div></th>
  </tr>
</table>
Country: Spain Spain |  OS: Unknown Unknown Browser: Unknown Unknown | View Profile

Offline Poffen

  • SOBI Team
  • Moderator
  • Sobi Hero
  • *
  • Posts: 2296
  • Reviews:

    What is it?

Re: Entry Count request not problem
« Reply #19 on: 05. July 2009, 14:16:14 »
Hi again,

Strange... I just tested the entire template code, as you have given it above, and it works for me.  ???

Try to empty all cache (joomla, sobi2 and browser) and see if that helps. If not, I'm sorry to say I can't help you any further. Maybe others here at forum can help you.

Alternatively, you can of course use the module I mentioned previously.

Poffen
Joomla - 1.5.7, Sobi2 - 2.9.0.1
PHP - 5.2.4, MySQL - 5.0.51a, Apache - 2.2.8, Firefox - 3.0.3
Country: Norway Norway |  OS: Unknown Unknown Browser: Unknown Unknown | View Profile

Tags: