Blog Stats

Discuss PivotX 2.0.x extensions here, and view extensions that are available for download.

Blog Stats

Postby Stingray » Tue Feb 23, 2010 8:51 pm

=== Added by hansfn 2011-06-11 ===

This extensions is now available on extensions.pivotx.net - see http://extensions.pivotx.net/entry/55/blogstats.

=== End addition ===

Information and download: http://pivotx.mobius-design.net/?p=blog-stats

If you upgraded to PivotX from PivotLog, you likely remember the extension called Total Posts. Well, I had looked into it and converted it and updated it for PivotX. I received Bram Nijmeijer's (formerly known as Tenshi) permission to release it, so I am.

Go to the link above or more information and to download the extension. There, you can also see a demonstration in the sidebar at that link.

Enjoy!
Last edited by Stingray on Wed Jun 08, 2011 4:12 am, edited 3 times in total.
Stingray
 
Posts: 107
Joined: Wed Oct 28, 2009 2:40 pm

Re: [REL] Blog Stats (version 1.1 released 3 March 2010)

Postby Stingray » Wed Mar 03, 2010 10:16 pm

Version 1.1 released.

hansfn is amazing! He has helped me to update and bug fix the snippet. Not that it didn't work before, but things are cleaner and smoother now. He's also suggested some ideas for a future release. Given time and ability, I'll be working on those things.
Stingray
 
Posts: 107
Joined: Wed Oct 28, 2009 2:40 pm

Re: [REL] Blog Stats (version 1.1 released 3 March 2010)

Postby Sanzine » Mon Mar 15, 2010 10:40 am

This is exactly the snippet I was waiting for here: http://forum.pivotx.net/viewtopic.php?f=2&t=1102!

However, I wouldn't be me when I didn't have an extra requirement... Currently I use the below code to display a menu based on the category list.

Code: Select all
<ul>
[[category_list format="<li><a %active% href='%url%'>%display%</a></li>" only="nederland, europa, azie, afrika, noord-amerika, zuid-amerika, caraibisch-gebied, australie, oceanie, treinreizen, cruises, accomodaties" isactive="id='active'" ]]
</ul>



The above code can be replaced by the below and show exactly the same, but then WITH the number of entries in each category, as I want. Unfortunately, there is no isactive parameter.

Code: Select all
<ul>
[[ blogstats
        prefix=""
        format="<li>%cat-link% (%entries%)</li>"
   include="nederland, europa, azie, afrika, noord-amerika, zuid-amerika, caraibisch-gebied, australie, oceanie, treinreizen, cruises, accomodaties"
        sort="pivotx"
]]
</ul>



Is there a way to incorporate this feature into [[ blogstats ]]?
Sanzine
 
Posts: 75
Joined: Tue Jan 20, 2009 10:15 am

Re: [REL] Blog Stats (version 1.1 released 3 March 2010)

Postby hansfn » Mon Mar 15, 2010 4:50 pm

It is trivial to add - just copy the corresponding code from the smarty_category_list funcion in modules/module_smarty.php. I assume Stingray will do it - he is competent enough. If not, I can do it later this week.
hansfn
Developer
 
Posts: 3280
Joined: Sun Nov 25, 2007 7:48 pm
Location: Molde, Norway

Re: [REL] Blog Stats (version 1.1 released 3 March 2010)

Postby Stingray » Tue Mar 16, 2010 5:19 am

Yeah...no problem. It'll be in the next release.

Right now, I've got a functioning update that'll count and display entries (and comments in those entries) per author. I need to work out some logistics and figure some stuff out on how I want it displayed.

In any event, an isactive feature should be easy enough to implement. Thanks for the request!
Stingray
 
Posts: 107
Joined: Wed Oct 28, 2009 2:40 pm

Re: [REL] Blog Stats (version 1.1 released 3 March 2010)

Postby Sanzine » Tue Mar 16, 2010 9:37 am

Great Stingray! I will be waiting for the next release then.
Sanzine
 
Posts: 75
Joined: Tue Jan 20, 2009 10:15 am

Re: [REL] Blog Stats (version 1.1 released 3 March 2010)

Postby Stingray » Tue Mar 16, 2010 2:35 pm

It is in 1.2. Expect it this week.

I'm playing around with the idea of changing the way %cat-link% works, too. Rather than writing out the full <a> tag, I am thinking about making it more like [[ category-list ]]. This would, of course, allow more customization, including putting %active% in the <a> tag, rather than wrapping %cat-link% in <li %active%> or <div %active%>.

hans, is there an equivalent to makeUserLink (as there is a makeCategoryLink)? My search of the references you sent me yielded nothing.
Stingray
 
Posts: 107
Joined: Wed Oct 28, 2009 2:40 pm

Re: [REL] Blog Stats (version 1.1 released 3 March 2010)

Postby hansfn » Tue Mar 16, 2010 9:10 pm

Nope, there is no makeUserLink - there hasn't been a need yet. You can use the following code (untested):

Code: Select all
$link = $PIVOTX['weblogs']->get('','link');
if ($PIVOTX['config']->get('mod_rewrite')==0) {
    $link .= '&amp;u=' . $username;
} else {
    $link .= '?u=' . $username;
}
hansfn
Developer
 
Posts: 3280
Joined: Sun Nov 25, 2007 7:48 pm
Location: Molde, Norway

Re: [REL] Blog Stats (version 1.1 released 3 March 2010)

Postby Stingray » Tue Mar 16, 2010 11:02 pm

hans,

What you wrote works, except that it puts a ?w=weblog in the link (domain.com/?w=weblog&u=[username]). From where I sit, the link still works, but for others including the weblog parameter might be undesirable.

I ended up copying and modifying the function makeCategoryLink to write the function makeUserLink:
Code: Select all
function makeUserLink($name, $override_weblog="") {
    global $PIVOTX;

    // Set the weblog, according to passed parameter or current weblog
    $weblog = get_default($override_weblog, $PIVOTX['weblogs']->getCurrent());
   
    $site_url = get_default($PIVOTX['weblogs']->get($weblog, 'site_url'), $PIVOTX['paths']['site_url']);
    if ($PIVOTX['config']->get('mod_rewrite') < 1) {
        $ulink = $site_url . "?u=" . $name;
    } else {
        $prefix = get_default($PIVOTX['config']->get('localised_user_prefix'), "user");
        $ulink = $site_url . makeURI($prefix) . "/" . $name;
    }

    // If we have more than one weblog, add the w=weblogname parameter
    if (para_weblog_needed($weblog)) {
        if ($PIVOTX['config']->get('mod_rewrite')>0) {
            // we treat it as an extra 'folder'
            $ulink .= "/" . $weblog;
        } else {
            $ulink .= "&amp;w=" . $weblog;
        }
    }

    return $ulink;

The only part(s) I'm unsure about is the mod_rewrite parts and this line:
Code: Select all
$prefix = get_default($PIVOTX['config']->get('localised_user_prefix'), "user");


I don't use mod_rewrite in conjunction with PivotX, at least, insofar as my PivotX is configured (I do use mod_rewrite otherwise, so I am familiar with it). So, I don't know if a username can be passed through a mod_rewritten link. Therefore, I'm also not sure if that line would work or not. I've only gotten so far as to put that function in the code and test it on my non-mod_rewrite PivotX site; it works there, so far--I'm short on time right now, so I can't go any further for the moment.

What are your thoughts?

I might be able to come back to the snippet some more tonight...certainly for a little bit tomorrow.
Stingray
 
Posts: 107
Joined: Wed Oct 28, 2009 2:40 pm

Re: [REL] Blog Stats (version 1.1 released 3 March 2010)

Postby hansfn » Wed Mar 17, 2010 1:46 am

First of all, making a modified version of makeCategoryLink seems like the obvious thing to do. However, there were some reasons I didn't suggest that - the same reasons we haven't created the function yet:

1) A category link will give you all entries in that category (independent of weblog). However, a user link will give you only the entries written by that user in a specific weblog.
2) A user can have written both entries and page, but the user link only returns the entries. (Pages don't have categories so there is no such problem for categories.)

So to make it clear what you get from a user link a decided to include the weblog parameter. When we have fixed the user link, at least issue 1 above, I'll create a function makeUserLink (or makeAuthorLink).

The mod_rewrite parameter/prefix for a user link is "author" - see example.htaccess.

NB! Never give a function a name that is likely to be used in the core. Multiple definitions of the same function is a fatal error.
hansfn
Developer
 
Posts: 3280
Joined: Sun Nov 25, 2007 7:48 pm
Location: Molde, Norway

Next

Return to 2.x Extensions

Who is online

Users browsing this forum: No registered users and 2 guests

cron