a ">

[Mod] Add Statistics to Homepage

  • Hi,

    I don't know, if anybody use tis small Mod.

    http://www.w-lansecure.biz/images/stat.gif

    By this way, thanks to all people who develop mods and send tips.

    Jappi

    Sorry, that I announce myself only today

    At first create a new File like "statistic.php", insert following Code:

    //Statistik
    $total_links = $db->GetOne("SELECT COUNT(*) FROM `{$tables['link']['name']}` WHERE `STATUS` = 2");
    $tpl->assign('total_links', $total_links);

    $pending_links = $db->GetOne("SELECT COUNT(*) FROM `{$tables['link']['name']}` WHERE `STATUS` = 1");
    $tpl->assign('pending_links', $pending_links);

    $today_links = $db->GetOne("SELECT COUNT(*) FROM `{$tables['link']['name']}` WHERE `DATE_ADDED` >= CURRENT_DATE");
    $tpl->assign('today_links', $today_links);

    $categorys = $db->GetOne("SELECT COUNT(*) FROM `{$tables['category']['name']}` WHERE `PARENT_ID` = 0 ");
    $tpl->assign('categorys', $categorys);

    $subcategorys = $db->GetOne("SELECT COUNT(*) FROM `{$tables['category']['name']}` WHERE `PARENT_ID` > 0 ");
    $tpl->assign('subcategorys', $subcategorys);
    //Ende Statistik
    ?>


    next open index.php and search for:

    // Paging 4
    $tpl->assign('list_total', count($count));
    // End Paging 4

    and insert Code below.


    require_once 'statistic.php';


    Now you can use the 5 variables in your templates whereever you want.

    For example in my left.tpl:



    {$categorys}

    {$subcategorys}


    {$total_links}

    {$pending_links}

    {$today_links}


    {l}Categorys:{/l}

    {l}Subcategorys:{/l}

    {l}Entries{/l}

    {l}Total:{/l}

    {l}Pending:{/l}

    {l}Today:{/l}



    If you want use this Layout, insert in your main.css:

    #statistic {
    margin: 0px;
    padding: 13px;
    border: 1px solid #8B008B;
    font-size: 7pt;
    line-height: 12px;
    }
    .statistic {
    float: right;
    font-weight: bold;
    padding-right: 5px;
    text-align: right;
    }

    Ok, have fun

    I hope phpLD 3.0 use the same tablefields as 2.0

    Jappi


  • Here is the deal.

    I will do it for a small fee or donation

    If you know where you want it it takes all of 5 minutes


  • Will anyone install this mod for me for a fee?

    - MENJ


  • I have mine in index on some and init on others both work for me but init makes it display on all pages


  • I like the idea of this one but all I am getting on my main index is this code:
    "Categorys:Subcategorys:EntriesTotal:Pending:Today:"

    Any ideas please?


  • Im sorry, didnt make myself clear, I cannot locate

    // Paging 4
    $tpl->assign('list_total', count($count));
    // End Paging 4

    in the index.php file of 3.0.4


  • Ok... here goes.... if you can't get it working after this, then there must be something else wrong somewhere. Just edit out the stats you do not want...

    In 'init.php', right before the '?>' at the very end....


    //ADDED CODE TO SHOW STATISTICS

    // Featured Link Counter
    $stat_featured = $db->GetOne("SELECT COUNT(*) FROM `{$tables['link']['name']}` WHERE `STATUS` = 2 AND `FEATURED` = 1 ");
    $tpl->assign('stat_featured', $stat_featured);
    // End

    // Total Links Counter
    $total_links = $db->GetOne("SELECT COUNT(*) FROM `{$tables['link']['name']}` WHERE `STATUS` = 2");
    $tpl->assign('total_links', $total_links);
    //End

    //Links NOT active Counter
    $unverified = $db->GetOne("SELECT COUNT(*) FROM `{$tables['link']['name']}` WHERE `STATUS` = 0");
    $tpl->assign('unverified', $unverified);
    //End

    // Awaiting Admin Review Counter
    $pending_links = $db->GetOne("SELECT COUNT(*) FROM `{$tables['link']['name']}` WHERE `STATUS` = 1");
    $tpl->assign('pending_links', $pending_links);
    //End

    // Links submitted today counter
    $today_links = $db->GetOne("SELECT COUNT(*) FROM `{$tables['link']['name']}` WHERE `DATE_ADDED` >= CURRENT_DATE");
    $tpl->assign('today_links', $today_links);
    //End

    //Total categories counter
    $categorys = $db->GetOne("SELECT COUNT(*) FROM `{$tables['category']['name']}` WHERE `PARENT_ID` = 0 ");
    $tpl->assign('categorys', $categorys);
    //End

    //Sub categories Counter
    $subcategorys = $db->GetOne("SELECT COUNT(*) FROM `{$tables['category']['name']}` WHERE `PARENT_ID` > 0 ");
    $tpl->assign('subcategorys', $subcategorys);
    //End

    //Total Articles Counter
    $articlecount = $db->GetOne("SELECT COUNT(*) FROM `{$tables['article']['name']}` WHERE `STATUS` = 2");
    $tpl->assign('articlecount', $articlecount);
    //End

    //Total Members counter
    $members = $db->GetOne("SELECT COUNT(*) FROM `{$tables['user']['name']}` WHERE `ACTIVE` = 1");
    $tpl->assign('members', $members);
    //End

    //Total Images counter (for those with image mod)
    $imagecount = $db->GetOne("SELECT COUNT(*) FROM `{$tables['image']['name']}` WHERE `STATUS` = 2");
    $tpl->assign('imagecount', $imagecount);
    //End

    //Links yesterday counter
    $yes = time()-86400;
    $yesterday = date("Ymd",$yes);
    $yesterday_links = $db->GetOne("SELECT COUNT(*) FROM `{$tables['link']['name']}` WHERE `DATE_ADDED` < CURRENT_DATE AND `DATE_ADDED` >= ".$yesterday);
    $tpl->assign('yesterday_links', $yesterday_links);
    //End

    //Last 7 days counter
    $week = time()-604800;
    $this_week = date("Ymd",$week);
    $this_weeks_links = $db->GetOne("SELECT COUNT(*) FROM `{$tables['link']['name']}` WHERE `DATE_ADDED` >= ".$this_week);
    $tpl->assign('this_weeks_links', $this_weeks_links);
    //End

    //Referred Traffic counter (traffic out)
    $traffic = $db->GetOne("SELECT SUM(HITS) FROM {$tables['link']['name']} WHERE STATUS = 2");
    $tpl->assign('traffic', $traffic);
    //End
    In your template file put each of these anywhere you want the stats to show:-


    {$stat_featured}
    {$total_links}
    {$unverified}
    {$pending_links}
    {$today_links}
    {$categorys}
    {$subcategorys}
    {$articlecount}
    {$members}
    {$imagecount}
    {$yesterday_links}
    {$this_weeks_links}
    {$traffic}
    You can see my working stats at www.u-hits.com (http://www.u-hits.com) in the left panel at the bottom. You can also use the same method to show the stats for page-ranks totals as I've done, but I'm sure that if you can get the above to work, you should be able to work that one out yourself!!

    Bruce.

    this worked great thank you very much. I have one question, what does traffic mean? is that the traffic online? or total traffic to the site? Mine currently says 5


  • has anyone updated the steps for 3.1 ?

    I didn't see the info in the index.php :confused:

    it's already setup for the template

    http://directory.vbulletinsetup.com

    thanks for the help

    -Bs


  • Very coooooool mod!!! Super i'll use it for all my sites !!!!!


  • Then I cannot help any further. The code I posted is exactly what I use on my site and it works perfectly. Maybe it's your version: I'm running on 3.2, but i can't really see why it won't work on any version that uses the named database fields. Try cutting and pasting the code EXACTLY as I put it but direct into your pages. If that doesn't work, then you have another problem somewhere. If it does work, then you can cut it out and put it into seperate template files.


    Ok I chnaged it to:

    {strip}



    Main Categories - {$categorys} Sub Categories - {$subcategorys} Active Links {$total_links} Pending Links - {$pending_links} Today's Links - {$today_links}


  • I have no clue system32, I made copies of all the files that I had to alter, when it didn't work I just put the backups back into place... should have gone back to default I would have thought?


  • That won't work either.... the variable names are still mis-matched! (re... categorys and categories). Sheeesh. :rolleyes:



    ok I will show you how to do that make a php file (call it statistic.php or what ever) with the following code
    //Stats
    $total_links = $db->GetOne("SELECT COUNT(*) FROM `{$tables['link']['name']}` WHERE `STATUS` = 2");
    $tpl->assign('total_links', $total_links);

    $pending_links = $db->GetOne("SELECT COUNT(*) FROM `{$tables['link']['name']}` WHERE `STATUS` = 1");
    $tpl->assign('pending_links', $pending_links);

    $today_links = $db->GetOne("SELECT COUNT(*) FROM `{$tables['link']['name']}` WHERE `DATE_ADDED` >= CURRENT_DATE");
    $tpl->assign('today_links', $today_links);

    $categorys = $db->GetOne("SELECT COUNT(*) FROM `{$tables['category']['name']}` WHERE `PARENT_ID` = 0 ");
    $tpl->assign('categorys', $categorys);

    $subcategorys = $db->GetOne("SELECT COUNT(*) FROM `{$tables['category']['name']}` WHERE `PARENT_ID` > 0 ");
    $tpl->assign('subcategorys', $subcategorys);
    //End Stats
    ?>
    now make a stats.tpl with this in it

    {strip}



    Main Categories - {$total_categories} Sub Categories - {$total_subcategories} Active Links {$total_active_links} Pending Links - {$total_pending_links} Today's Links - {$total_todays_links}


  • I didn't want to wait long so I replaced all my .bak files with the ones I altered for this mod.... now all I get is:
    "public_html/search/libs/smarty/Smarty.class.php on line 1095"

    Any ideas please?.....


  • i got the today's added links to work
    in index.php
    $stats[2] = $db->GetOne("SELECT COUNT(*) FROM {$tables['link']['name']} WHERE STATUS = 2 AND `DATE_ADDED` >= CURRENT_DATE ");
    $tpl->assign('stats', $stats);
    in whatever.tpl
    {$stats[2]} {l}Approved Links Today{/l}


  • if you are having problems, i've put together a "mod" from mods in this forum some are as is from posts others I put together and some I had to alter to make them work for my site...

    feel free to check it out on my mods page
    http://www.shadav.info/mods.php
    demo of them running are in the top bar


  • did you put all of the codes into the init.php instead of the index.php?
    placing the codes into the init.php file will allow it to be displayed on all pages of your directory.


  • i am not able to get the today links to work....can anyone help, i have version 2.1.1

    also between this and the other thread (which i can't find at the moment) I was able to change things up a bit...
    To display how many Featured listings you have
    in the index.php
    find
    echo $tpl->fetch('main.tpl', $id);
    ?>add before
    $stat_featured = $db->GetOne("SELECT COUNT(*) FROM `{$tables['link']['name']}` WHERE `STATUS` = 2 AND `FEATURED` = 1 ");
    $tpl->assign('stat_featured', $stat_featured);then in whatever .tpl file you want it to display
    {$stat_featured} {l}Featured Links{/l}
    to Display how many Regular Listings
    as as before in the index.php put in
    $stats[0] = $db->GetOne("SELECT COUNT(*) FROM {$tables['link']['name']} WHERE STATUS = 2 AND `FEATURED` = 0 ");
    $tpl->assign('stats', $stats);then in whatever .tpl you want it in
    {$stats[0]} {l}Regular Links{/l}


  • Can someone explain what we have to do in the last phpld version so this mod can work?

    Thank you


  • Hmmm, it still displays vertical :/

    http://www.seodir.net


  • look at the end of the file

    //Make output
    echo $tpl->fetch ('main.tpl', $id);


  • Guys how to apply this stats in vertival position:

    http://img442.imageshack.us/img442/1821/verticalif3.jpg


    can someone place code for vertical ? :)


  • I saw your site also have "site by pagerank" do you have the code as well or point me somewhere I can find it? Thanks.

    =========================
    http://www.webpowerlink.com
    http://www.twinbees.com


  • how do we show "Sumbitted Yesterday: "?


  • I'm not entirely sure...I have 2.1.1 and i have them working but don't remember which ones I used from here or from this thread
    http://www.phplinkdirectory.com/forum/showthread.php?t=452


  • Can someone explain what we have to do in the last phpld version so this mod can work?

    Thank you

    Mmm any luck?

    Does anyone know if this works in 3.06 or has a solution.


  • Any reason why the stats mod doesn't work on the Submit.php page? But works on all the others?


  • Yes, I added that in my index.php:

    $stat_featured = $db->GetOne("SELECT COUNT(*) FROM `{$tables['link']['name']}` WHERE `STATUS` = 2 AND `FEATURED` = 1 ");
    $tpl->assign('stat_featured', $stat_featured);
    $total_links = $db->GetOne("SELECT COUNT(*) FROM `{$tables['link']['name']}` WHERE `STATUS` = 2");
    $tpl->assign('total_links', $total_links);
    $pending_links = $db->GetOne("SELECT COUNT(*) FROM `{$tables['link']['name']}` WHERE `STATUS` = 1");
    $tpl->assign('pending_links', $pending_links);
    $today_links = $db->GetOne("SELECT COUNT(*) FROM `{$tables['link']['name']}` WHERE `DATE_ADDED` >= CURRENT_DATE");
    $tpl->assign('today_links', $today_links);
    $categorys = $db->GetOne("SELECT COUNT(*) FROM `{$tables['category']['name']}` WHERE `PARENT_ID` = 0 ");
    $tpl->assign('categorys', $categorys);
    $subcategorys = $db->GetOne("SELECT COUNT(*) FROM `{$tables['category']['name']}` WHERE `PARENT_ID` > 0 ");
    $tpl->assign('subcategorys', $subcategorys);
    $yes = time()-86400;
    $yesterday = date("Ymd",$yes);
    $yesterday_links = $db->GetOne("SELECT COUNT(*) FROM `{$tables['link']['name']}` WHERE `DATE_ADDED` < CURRENT_DATE AND `DATE_ADDED` >= ".$yesterday);
    $tpl->assign('yesterday_links', $yesterday_links);
    ?>


    I am using version 3.2 on private dedicated server, maybe I have some disabled options in php ?


  • yes, if you release a mod i think i will use it :)


  • I dont have this two files but I will PM you my index.php and main.tpl.


    P.S. I cant attach files, so here are they:


    http://www.seodir.net/index.txt
    http://www.seodir.net/main.tpl.txt


  • Thx for this mod...is great ....


  • Thanks alot for the "Mod for dummies" working like a charm now.


  • The statistics weren't showing up on the details page, so I added the code to details.php as well:

    require_once 'statistics.php';

    right under:

    require_once 'init.php';

    So now the stats show up on the details page as well.

    Joanne


    I have to add to these files too:

    submit.php
    payment.php

    So now the statistics show in the submit page and the payment page.

    By the way, great mod :)


  • Stats displaying I have added in main.tpl:

    {* Javascript for tracking link clicks *}
    {if $StopLinkHits eq 0}

    {/if}

    Main Categories - {$total_categories} Sub Categories - {$total_subcategories} Active Links {$total_active_links} Pending Links - {$total_pending_links} Today's Links - {$total_todays_links}

    {include file="footer.tpl"}
    {/strip}

    Is this ok ? Its not beign displayed :(


    Please can someone post now the full mod ? what need to be added, where etc...
    I want all things that can be displayed, featured listings etc... all stats and the codes for. Please ? :)


  • I have not found where hear, will work in versions 2.1? or only from 3 and senior?

    thanks
    Nikola


  • Not sure if its the mod or the site but I have noticed one small issue I would like to know if anyone has seen and know of a fix.
    if you get
    20 submissions saturday
    23 on sunday
    44 on monday

    and you didnt approve any links over the weekend then on monday you play catch up or start reviewing and approving the links. However the links for saturday and sunday do no not count towards the "approved links" only the links submitted on monday are counting. SO its only counting the links that are approved on the same day of submission.

    Is it possible to fix this or is there a fix I missed so it counts all of them no matter when they were submitted?


  • Well it should be pretty obvious if you compare! Take a look your variable names... they do not match! That's why they are not displaying!


    In your main page you have....

    Main Categories - {$total_categories} Sub Categories - {$total_subcategories} Active Links {$total_active_links} Pending Links - {$total_pending_links} Today's Links - {$total_todays_links}

    Change it to...

    Main Categories - {$categories} Sub Categories - {$subcategories} Active Links {$total_links} Pending Links - {$pending_links} Today's Links - {$today_links}

    Bruce.


  • Is there a today's hit and total hits counter statistics?


  • do we put the whole code or just the require_once 'statistic.php';just a note...i've gotten these to work on 3.2

    and instead of putting the codes in index.php place them in init.php before the ?> and the statistics will show on every page of your directory :)


  • In php file where you get stats:
    ---------------------------------------------

    $yes = time()-86400;
    $yesterday = date("Ymd",$yes);
    $yesterday_links = $db->GetOne("SELECT COUNT(*) FROM `{$tables['link']['name']}` WHERE `DATE_ADDED` < CURRENT_DATE AND `DATE_ADDED` >= ".$yesterday);
    $tpl->assign('yesterday_links', $yesterday_links);

    in .tpl file where you display stats:
    --------------------------------------------------

    {l}Yesterday links: {/l}{$yesterday_links){/l}

    I hope I could you help

    Christian


  • Ok I chnaged it to:

    {strip}



    Main Categories - {$categorys} Sub Categories - {$subcategorys} Active Links {$total_links} Pending Links - {$pending_links} Today's Links - {$today_links}


  • i have it working with a little change...

    instead of building a new php file called statistics.php i put the code for this file directly in index php, right above
    echo $tpl->fetch('main.tpl', $id);


  • nice project... congrulations.


  • I am using 3.0.4 I could not locate

    // Paging 4
    $tpl->assign('list_total', count($count));
    // End Paging 4

    anywhere in index.php

    Am I missing something or is this for a different version?
    I would like to use this if I can make it work.

    Thanks!


  • Hello I can also install it for a small fee :P

    shadav so its beter to add it into index.php ?


  • Does anyone know how to display: Approved Today?


  • Does anyone know what I can do?


  • Just taking the most important information on the site like links and pending.

    Thanks for the mod


  • I would place the code itself in the init.php


  • just a note...i've gotten these to work on 3.2

    and instead of putting the codes in index.php place them in init.php before the ?> and the statistics will show on every page of your directory :)


  • yeah i once was terrible at scripting i am not really that good yet
    but hey i am coming along :)


  • Traffic is the total of hits you have sent out to sites.


  • remove the
    ...


  • I can now confirm this works for 3.06, but this


    // Paging 4
    $tpl->assign('list_total', count($count));
    // End Paging 4


    ...does not exist. Simply add:

    require_once 'statistic.php';

    Underneath:


    require_once 'init.php';



    And its all fine.


  • {* Calculate title from path *}
    {capture name="title"}
    {if count($path) > 1} - {/if}
    {foreach from=$path item=category name=path}
    {if $smarty.foreach.path.iteration gt 2}
    >
    {/if}
    {if not $smarty.foreach.path.first}
    {$category.TITLE}
    {/if}
    {/foreach}
    {/capture}

    {strip}
    {if $title_prefix}
    {assign var="in_page_title" value=$title_prefixcat:$category.TITLE}
    {else}
    {assign var="in_page_title" value=$category.TITLE}
    {/if}
    {assign var="description" value=$category.DESCRIPTION}

    {include file="header.tpl"}

    {include file="top_bar.tpl"}

    {* Calculate the number of categories per row *}
    {php}
    $this->assign('cats_per_col', ceil(count($this->get_template_vars('categs')) / CATS_PER_ROW));
    {/php}

    {if $cats_per_col > 15}
    {php}
    $this->assign('cats_per_col', ceil(count($this->get_template_vars('categs')) / (CATS_PER_ROW + 1)));
    {/php}
    {/if}

    {* Show category search results *}
    {if $search_category}
    {$search_category}
    {/if}

    {* Show article search results *}
    {if $search_article}
    {$search_article}
    {/if}

    {if isset($have_search_results) and $have_search_results == 0}

    {l}Sorry, no records found that match your keyword(s){/l}: "{$searchescapewordwrap:200:"n":true}"


    {l}Suggestions{/l}:




    • {l}Make sure all words are spelled correctly{/l}.

    • {l}Try different keywords{/l}.

    • {l}Try more general keywords{/l}.





  • i would use it if you could send the code


  • Ok... here goes.... if you can't get it working after this, then there must be something else wrong somewhere. Just edit out the stats you do not want...

    In 'init.php', right before the '?>' at the very end....


    //ADDED CODE TO SHOW STATISTICS

    // Featured Link Counter
    $stat_featured = $db->GetOne("SELECT COUNT(*) FROM `{$tables['link']['name']}` WHERE `STATUS` = 2 AND `FEATURED` = 1 ");
    $tpl->assign('stat_featured', $stat_featured);
    // End

    // Total Links Counter
    $total_links = $db->GetOne("SELECT COUNT(*) FROM `{$tables['link']['name']}` WHERE `STATUS` = 2");
    $tpl->assign('total_links', $total_links);
    //End

    //Links NOT active Counter
    $unverified = $db->GetOne("SELECT COUNT(*) FROM `{$tables['link']['name']}` WHERE `STATUS` = 0");
    $tpl->assign('unverified', $unverified);
    //End

    // Awaiting Admin Review Counter
    $pending_links = $db->GetOne("SELECT COUNT(*) FROM `{$tables['link']['name']}` WHERE `STATUS` = 1");
    $tpl->assign('pending_links', $pending_links);
    //End

    // Links submitted today counter
    $today_links = $db->GetOne("SELECT COUNT(*) FROM `{$tables['link']['name']}` WHERE `DATE_ADDED` >= CURRENT_DATE");
    $tpl->assign('today_links', $today_links);
    //End

    //Total categories counter
    $categorys = $db->GetOne("SELECT COUNT(*) FROM `{$tables['category']['name']}` WHERE `PARENT_ID` = 0 ");
    $tpl->assign('categorys', $categorys);
    //End

    //Sub categories Counter
    $subcategorys = $db->GetOne("SELECT COUNT(*) FROM `{$tables['category']['name']}` WHERE `PARENT_ID` > 0 ");
    $tpl->assign('subcategorys', $subcategorys);
    //End

    //Total Articles Counter
    $articlecount = $db->GetOne("SELECT COUNT(*) FROM `{$tables['article']['name']}` WHERE `STATUS` = 2");
    $tpl->assign('articlecount', $articlecount);
    //End

    //Total Members counter
    $members = $db->GetOne("SELECT COUNT(*) FROM `{$tables['user']['name']}` WHERE `ACTIVE` = 1");
    $tpl->assign('members', $members);
    //End

    //Total Images counter (for those with image mod)
    $imagecount = $db->GetOne("SELECT COUNT(*) FROM `{$tables['image']['name']}` WHERE `STATUS` = 2");
    $tpl->assign('imagecount', $imagecount);
    //End

    //Links yesterday counter
    $yes = time()-86400;
    $yesterday = date("Ymd",$yes);
    $yesterday_links = $db->GetOne("SELECT COUNT(*) FROM `{$tables['link']['name']}` WHERE `DATE_ADDED` < CURRENT_DATE AND `DATE_ADDED` >= ".$yesterday);
    $tpl->assign('yesterday_links', $yesterday_links);
    //End

    //Last 7 days counter
    $week = time()-604800;
    $this_week = date("Ymd",$week);
    $this_weeks_links = $db->GetOne("SELECT COUNT(*) FROM `{$tables['link']['name']}` WHERE `DATE_ADDED` >= ".$this_week);
    $tpl->assign('this_weeks_links', $this_weeks_links);
    //End

    //Referred Traffic counter (traffic out)
    $traffic = $db->GetOne("SELECT SUM(HITS) FROM {$tables['link']['name']} WHERE STATUS = 2");
    $tpl->assign('traffic', $traffic);
    //End
    In your template file put each of these anywhere you want the stats to show:-


    {$stat_featured}
    {$total_links}
    {$unverified}
    {$pending_links}
    {$today_links}
    {$categorys}
    {$subcategorys}
    {$articlecount}
    {$members}
    {$imagecount}
    {$yesterday_links}
    {$this_weeks_links}
    {$traffic}
    You can see my working stats at www.u-hits.com (http://www.u-hits.com) in the left panel at the bottom. You can also use the same method to show the stats for page-ranks totals as I've done, but I'm sure that if you can get the above to work, you should be able to work that one out yourself!!

    Bruce.


    Thanks So much Bruce, this works great for me, I am using it on ZetaUrl.com

    :D


  • Do you have the other code that's required inside your index.php or init.php pages??


  • Nothing helped.

    Thx for trying to help me guys... :)


  • The statistics weren't showing up on the details page, so I added the code to details.php as well:

    require_once 'statistics.php';

    right under:

    require_once 'init.php';

    So now the stats show up on the details page as well.

    Joanne


  • Ok... here goes.... if you can't get it working after this, then there must be something else wrong somewhere. Just edit out the stats you do not want...

    In 'init.php', right before the '?>' at the very end....


    //ADDED CODE TO SHOW STATISTICS

    // Featured Link Counter
    $stat_featured = $db->GetOne("SELECT COUNT(*) FROM `{$tables['link']['name']}` WHERE `STATUS` = 2 AND `FEATURED` = 1 ");
    $tpl->assign('stat_featured', $stat_featured);
    // End

    // Total Links Counter
    $total_links = $db->GetOne("SELECT COUNT(*) FROM `{$tables['link']['name']}` WHERE `STATUS` = 2");
    $tpl->assign('total_links', $total_links);
    //End

    //Links NOT active Counter
    $unverified = $db->GetOne("SELECT COUNT(*) FROM `{$tables['link']['name']}` WHERE `STATUS` = 0");
    $tpl->assign('unverified', $unverified);
    //End

    // Awaiting Admin Review Counter
    $pending_links = $db->GetOne("SELECT COUNT(*) FROM `{$tables['link']['name']}` WHERE `STATUS` = 1");
    $tpl->assign('pending_links', $pending_links);
    //End

    // Links submitted today counter
    $today_links = $db->GetOne("SELECT COUNT(*) FROM `{$tables['link']['name']}` WHERE `DATE_ADDED` >= CURRENT_DATE");
    $tpl->assign('today_links', $today_links);
    //End

    //Total categories counter
    $categorys = $db->GetOne("SELECT COUNT(*) FROM `{$tables['category']['name']}` WHERE `PARENT_ID` = 0 ");
    $tpl->assign('categorys', $categorys);
    //End

    //Sub categories Counter
    $subcategorys = $db->GetOne("SELECT COUNT(*) FROM `{$tables['category']['name']}` WHERE `PARENT_ID` > 0 ");
    $tpl->assign('subcategorys', $subcategorys);
    //End

    //Total Articles Counter
    $articlecount = $db->GetOne("SELECT COUNT(*) FROM `{$tables['article']['name']}` WHERE `STATUS` = 2");
    $tpl->assign('articlecount', $articlecount);
    //End

    //Total Members counter
    $members = $db->GetOne("SELECT COUNT(*) FROM `{$tables['user']['name']}` WHERE `ACTIVE` = 1");
    $tpl->assign('members', $members);
    //End

    //Total Images counter (for those with image mod)
    $imagecount = $db->GetOne("SELECT COUNT(*) FROM `{$tables['image']['name']}` WHERE `STATUS` = 2");
    $tpl->assign('imagecount', $imagecount);
    //End

    //Links yesterday counter
    $yes = time()-86400;
    $yesterday = date("Ymd",$yes);
    $yesterday_links = $db->GetOne("SELECT COUNT(*) FROM `{$tables['link']['name']}` WHERE `DATE_ADDED` < CURRENT_DATE AND `DATE_ADDED` >= ".$yesterday);
    $tpl->assign('yesterday_links', $yesterday_links);
    //End

    //Last 7 days counter
    $week = time()-604800;
    $this_week = date("Ymd",$week);
    $this_weeks_links = $db->GetOne("SELECT COUNT(*) FROM `{$tables['link']['name']}` WHERE `DATE_ADDED` >= ".$this_week);
    $tpl->assign('this_weeks_links', $this_weeks_links);
    //End

    //Referred Traffic counter (traffic out)
    $traffic = $db->GetOne("SELECT SUM(HITS) FROM {$tables['link']['name']} WHERE STATUS = 2");
    $tpl->assign('traffic', $traffic);
    //End


    In your template file put each of these anywhere you want the stats to show:-


    {$stat_featured}
    {$total_links}
    {$unverified}
    {$pending_links}
    {$today_links}
    {$categorys}
    {$subcategorys}
    {$articlecount}
    {$members}
    {$imagecount}
    {$yesterday_links}
    {$this_weeks_links}
    {$traffic}


    You can see my working stats at www.u-hits.com (http://www.u-hits.com) in the left panel at the bottom. You can also use the same method to show the stats for page-ranks totals as I've done, but I'm sure that if you can get the above to work, you should be able to work that one out yourself!!

    Bruce.


  • ummm... no help?


  • ok thank you as I have mod on all my 3.2 sites so I can't figure out why its not working on yours


  • I have released a mod for phpLinkDirectory 2.0 and 3.0.5+. that allows you to show statistics on the front of your directory relating to the links and categories in the database. You can see what it looks like at http://www.moondirectory.co.uk (http://www.moondirectory.co.uk/).


    The idea was originally by Jappi at phpLinkDirectory Forums. I have made a few changes in this version.
    Added Featured Link Count.
    Replaced Categories and Subcategories with a total category count.
    Updated HTML to use DIV tags with stylesheets.You can download the code and source needed to implement in the phpLD Statistics Mod (http://www.directoryspy.com/downloads/phpld-statistics-mod/) section at DirectorySpy.com


  • Added a few more to my previous post. These I worked out for myself, so I thought I'd share with everyone.

    Show Total members.

    Add this to init.php


    $members = $db->GetOne("SELECT COUNT(*) FROM `{$tables['user']['name']}` WHERE `ACTIVE` = 1");
    $tpl->assign('members', $members);


    Add to template where you want it to show:-

    {$members}

    Show total articles:-

    Add this to init.php:-

    $articlecount = $db->GetOne("SELECT COUNT(*) FROM `{$tables['article']['name']}` WHERE `STATUS` = 2");
    $tpl->assign('articlecount', $articlecount);

    Add to template where you want it to show:-

    {$articlecount}

    Again, only tested with version 3.2. Enjoy....

    Bruce.
    http://www.u-hits.com - Free website submission.
    http://www.awayaway.com - Your online source for travel related products, services and information.
    http://www.u-pixx.com - Effective Pixel Advertising.


  • I cant get this to work on 3.2, anyone have a guide "for dummies" on how to make this mod work on 3.2?


  • Will anyone install this mod for me for a fee?

    - MENJ

    If Dawzz or Shadav don't I will try as I have it on all my sites


  • I did it now, but still nothing happends.


  • Is there a way to do this with 3.0.4?


  • Can someone help me ?
    The stats arent displayedon my directory:
    http://www.seodir.net :(


  • I know I have a template somewhere on my pc that has it in the footer just can't find it
    like this maybe Main Categories - {$total_categories} Sub Categories - {$total_subcategories} Active Links {$total_active_links} Pending Links - {$total_pending_links} Today's Links - {$total_todays_links}


  • Ok, just for reference and to make it easier for people to adapt to their sites, this is what I did. I made a few small changes and put everything together from various posts in this thread and I have got this. (Formatted for my site).

    To display statistics for, Categories, Sub-categories, Total Sites, Today, Yesterday, Featured Sites and Pending sites on ALL pages, add the following to the end of the init.php file right before '"php>".


    $stat_featured = $db->GetOne("SELECT COUNT(*) FROM `{$tables['link']['name']}` WHERE `STATUS` = 2 AND `FEATURED` = 1 ");
    $tpl->assign('stat_featured', $stat_featured);
    $total_links = $db->GetOne("SELECT COUNT(*) FROM `{$tables['link']['name']}` WHERE `STATUS` = 2");
    $tpl->assign('total_links', $total_links);
    $pending_links = $db->GetOne("SELECT COUNT(*) FROM `{$tables['link']['name']}` WHERE `STATUS` = 1");
    $tpl->assign('pending_links', $pending_links);
    $today_links = $db->GetOne("SELECT COUNT(*) FROM `{$tables['link']['name']}` WHERE `DATE_ADDED` >= CURRENT_DATE");
    $tpl->assign('today_links', $today_links);
    $categorys = $db->GetOne("SELECT COUNT(*) FROM `{$tables['category']['name']}` WHERE `PARENT_ID` = 0 ");
    $tpl->assign('categorys', $categorys);
    $subcategorys = $db->GetOne("SELECT COUNT(*) FROM `{$tables['category']['name']}` WHERE `PARENT_ID` > 0 ");
    $tpl->assign('subcategorys', $subcategorys);
    $yes = time()-86400;
    $yesterday = date("Ymd",$yes);
    $yesterday_links = $db->GetOne("SELECT COUNT(*) FROM `{$tables['link']['name']}` WHERE `DATE_ADDED` < CURRENT_DATE AND `DATE_ADDED` >= ".$yesterday);
    $tpl->assign('yesterday_links', $yesterday_links);


    On the template you want to add your stats add the following:-


















    Statistics
    {l}Categories:{/l}
    {$categorys}
    {l}Sub Categories:{/l}
    {$subcategorys}
    {l}Total Sites:{/l}
    {$total_links}
    {l}Featured Sites:{/l}
    {$stat_featured}
    {l}Pending Sites:{/l}
    {$pending_links}
    {l}Today:{/l}
    {$today_links}
    {l}Yesterday:{/l}
    {$yesterday_links}




    These are the styles I used in my style sheet:-


    .stats1 {
    font-weight: bold;
    color: gray;
    text-align: left;
    font-size: 10px;
    background: #0f0f0f;
    }
    .stats2 {
    font-weight: bold;
    color: white;
    text-align: right;
    font-size: 11px;
    background: #0f0f0f;
    }


    There may be better ways to achieve this, but I am not a PHP coder, so this way suits me. For reference, I am using version 3.2 of PHPLD and it seems to work fine on my site.

    See www.u-hits.com (http://www.u-hits.com) and scroll down and look in the left panel to see what all the above looks like.

    Bruce.


  • how it works in latest version?


  • just checking...

    Does "stats" work with V3.1 ?

    thanks in adv...
    James.


  • I did it now, but still nothing happends.


    can you pm me your index.php and the tpl where you have your stats loaded and I will check it out as I know I gave you the correct code so it should display also your stats.tpl and statistic.php if you have one


  • but yes, lol... there are no numbers


  • Thanks for this mod. It use it with v2.1! :)


  • I just looked at the two files you posted and the names still do not match!

    For example you have "$categorys" in your php file, but have "$categories" in your template!

    If you just copy the code that I pasted earlier in this thread it will work.

    Bruce.

    NB. 'categories' isthe correct spelling!


    I dont have this two files but I will PM you my index.php and main.tpl.


    P.S. I cant attach files, so here are they:


    http://www.seodir.net/index.txt
    http://www.seodir.net/main.tpl.txt


  • That won't work either.... the variable names are still mis-matched! (re... categorys and categories). Sheeesh. :rolleyes:

    that was my fault did a copy and paste from wrong post:o


  • yeah in root
    Hey bobby, I saw your site http://www.text-link-ads.com/ , unfortunately doesn't have a category "Photography".


  • Hello,

    How do modify the code to show number of links added in the "Last 7 days" rather than "Today"?

    Thanks in advance!


  • does this work on 3.6.5?


  • Thanks for the MOD. This opens up lots of doors. You can use this to get lots of data and display it on the main pages.

    Thanks for the ideas.


  • ok, all files are replaced now and all is good:apart from:
    "Categorys:Subcategorys:EntriesTotal:Pending:Today:" on my left side?


  • which folder should create that statistic.php file? root?


  • apologies, mixed it up with my forums :p


  • Works with 3.0.6 ?
    Great mod :)


  • Thanks, worked great on my 3.2


  • many thanks, a complete script idiot like me got this up and running!
    bah! don't be so hard on yourself. Just think of it as not being versed enough(yet) ;)


  • Thanks a lot for this mod, I have used this for the statistics on my directory: http://ipage.info :)


  • has anyone updated the steps for 3.1 ?


  • I think something like this

    Main Categories - {$total_categories}
    Sub Categories - {$total_subcategories}
    Active Links {$total_active_links}
    Pending Links - {$total_pending_links}
    Today's Links - {$total_todays_links}


  • Ok... give me a few minutes and I'll paste Exactly what I have on mysite........


  • anything can be made to work but what version is it 3.06
    ?
    we dont have 3.6.5


  • very nice mod. :)


  • Sorry, i mean naturally, need and not to use.

    Simply Integration.
    Sorry for my bad english, look at my sign :roll:

    Jappi


  • just after where I have it bold add that code I have there in dex.php



    //Make output
    echo $tpl->fetch('main.tpl', $id);
    $total_categories = $db->GetOne("SELECT COUNT(*) FROM `{$tables['category']['name']}` WHERE `PARENT_ID` = 0 ");
    $tpl->assign('total_categories', $total_categories);
    $total_subcategories = $db->GetOne("SELECT COUNT(*) FROM `{$tables['category']['name']}` WHERE `PARENT_ID` > 0 ");
    $tpl->assign('total_subcategories', $total_subcategories);
    $total_active_links = $db->GetOne("SELECT COUNT(*) FROM `{$tables['link']['name']}` WHERE `STATUS` = 2");
    $tpl->assign('total_active_links', $total_active_links);
    $total_pending_links = $db->GetOne("SELECT COUNT(*) FROM `{$tables['link']['name']}` WHERE `STATUS` = 1");
    $tpl->assign('total_pending_links', $total_pending_links);
    $total_todays_links = $db->GetOne("SELECT COUNT(*) FROM `{$tables['link']['name']}` WHERE `DATE_ADDED` >= CURRENT_DATE");
    $tpl->assign('total_todays_links', $total_todays_links);
    $total_article = $db->GetOne("SELECT COUNT(*) FROM `{$tables['article']['name']}` WHERE `STATUS` = 2");
    $tpl->assign('total_article', $total_article);
    ?>


  • The bug is that mod is not displayed on other pages then index.php

    Submit for example, see it yourself http://www.phplddirectory.com/submit.php

    Or at least tell me how to display the mod only on main page.


  • I cannot find that in 3.04 either


  • In index.php is ok. But the others there isnt any numbers???


  • Hey i want to use that MOD in bar !

    Like as shadav have in his General web directory

    Thanks


  • yeah in root


  • ... its great :D!!!


  • Ok added without dt and dl but it seems that my stats arent displayed, is that so because I have added the code to init.php , I mean the code for functions in php.


  • thanks.. but still.. i get the server error message.. :(

    i tried to undo the changes i made.. and uploaded the file back.. but still.. the same error.. hpow can i get back from my directory without those smarty errors?


  • many thanks, a complete script idiot like me got this up and running!


  • gr8 mod

    live at www.webdirectory.cn (http://www.webdirectory.cn)

    Dave


  • Sorry, that I announce myself only today

    At first create a new File like "statistic.php", insert following Code:

    //Statistik
    $total_links = $db->GetOne("SELECT COUNT(*) FROM `{$tables['link']['name']}` WHERE `STATUS` = 2");
    $tpl->assign('total_links', $total_links);

    $pending_links = $db->GetOne("SELECT COUNT(*) FROM `{$tables['link']['name']}` WHERE `STATUS` = 1");
    $tpl->assign('pending_links', $pending_links);

    $today_links = $db->GetOne("SELECT COUNT(*) FROM `{$tables['link']['name']}` WHERE `DATE_ADDED` >= CURRENT_DATE");
    $tpl->assign('today_links', $today_links);

    $categorys = $db->GetOne("SELECT COUNT(*) FROM `{$tables['category']['name']}` WHERE `PARENT_ID` = 0 ");
    $tpl->assign('categorys', $categorys);

    $subcategorys = $db->GetOne("SELECT COUNT(*) FROM `{$tables['category']['name']}` WHERE `PARENT_ID` > 0 ");
    $tpl->assign('subcategorys', $subcategorys);
    //Ende Statistik
    ?>


    next open index.php and search for:

    // Paging 4
    $tpl->assign('list_total', count($count));
    // End Paging 4

    and insert Code below.


    require_once 'statistic.php';


    Now you can use the 5 variables in your templates whereever you want.

    For example in my left.tpl:



    {$categorys}

    {$subcategorys}


    {$total_links}

    {$pending_links}

    {$today_links}


    {l}Categorys:{/l}

    {l}Subcategorys:{/l}

    {l}Entries{/l}

    {l}Total:{/l}

    {l}Pending:{/l}

    {l}Today:{/l}



    If you want use this Layout, insert in your main.css:

    #statistic {
    margin: 0px;
    padding: 13px;
    border: 1px solid #8B008B;
    font-size: 7pt;
    line-height: 12px;
    }
    .statistic {
    float: right;
    font-weight: bold;
    padding-right: 5px;
    text-align: right;
    }

    Ok, have fun

    I hope phpLD 3.0 use the same tablefields as 2.0

    Jappi


  • ok I will show you how to do that make a php file (call it statistic.php or what ever) with the following code
    //Stats
    $total_links = $db->GetOne("SELECT COUNT(*) FROM `{$tables['link']['name']}` WHERE `STATUS` = 2");
    $tpl->assign('total_links', $total_links);

    $pending_links = $db->GetOne("SELECT COUNT(*) FROM `{$tables['link']['name']}` WHERE `STATUS` = 1");
    $tpl->assign('pending_links', $pending_links);

    $today_links = $db->GetOne("SELECT COUNT(*) FROM `{$tables['link']['name']}` WHERE `DATE_ADDED` >= CURRENT_DATE");
    $tpl->assign('today_links', $today_links);

    $categorys = $db->GetOne("SELECT COUNT(*) FROM `{$tables['category']['name']}` WHERE `PARENT_ID` = 0 ");
    $tpl->assign('categorys', $categorys);

    $subcategorys = $db->GetOne("SELECT COUNT(*) FROM `{$tables['category']['name']}` WHERE `PARENT_ID` > 0 ");
    $tpl->assign('subcategorys', $subcategorys);
    //End Stats
    ?>
    now make a stats.tpl with this in it

    {strip}



    Main Categories - {$total_categories} Sub Categories - {$total_subcategories} Active Links {$total_active_links} Pending Links - {$total_pending_links} Today's Links - {$total_todays_links}


  • I saw your site also have "site by pagerank" do you have the code as well or point me somewhere I can find it? Thanks.

    =========================
    http://www.webpowerlink.com
    http://www.twinbees.com

    Try phpLD Owners Mod List. Most mods are listed here. Some are paid. :eek:
    .


  • I used this mod in new design I am making. It will be available for free at www.phpldtemplates.info
    I changed html code and css also to make better control of it. You can see work in progres here: http://img63.imageshack.us/img63/5756/screen0tr.gif
    Also tell me your homepage url so I can credit you on my site when I release this one.


  • Edited the files but still dont shown... hmm you told something about stats.tpl etc, I do not have these files :/


  • lol her's but no prob :D
    you can place them anywhere you'd like them to be displayed
    I just added the codes to my header.tpl file
    the bar is part of my template however you should be able to basically do the same thing
    using the stye.css in the images folder created the bar
    style.css
    #banner_bottom {height: 24px; background: url('banner.bottom.gif');}
    then in the header.tpl file
    YOUR CODES


  • thanks guys, I just used the mod on my directory: http://directory.mrgoodfox.com/







  • #If you have any other info about this subject , Please add it free.#
    Your name:
    E-mail:
    Telphone:

    Your comments:


    If you have any other info about [Mod] Add Statistics to Homepage , Please add it free.