Part of the EllisLab Network
pMachine Pro has been replaced by ExpressionEngine, our full featured web publishing solution. Please consider upgrading.
You can download pMachine Pro here: Download pMachine Pro  |  Download Language Packs
   
 
weblog_title_list() format hack
Posted: 03 October 2004 09:28 AM   [ Ignore ]  
Grad Student
Avatar
Rank
Total Posts:  78
Joined  2002-06-01

In case anyone is interested, I’ve created a hack to the weblog_title_list() function that gives it more flexibility.  The hack allows the following:

Adds an addition option to the “orderby” parameter to allow for ordering by most recent comment (in addition to the existing “newest”, “oldest”, and “alpha”)

$wtl['orderby'] = "[i]recent[/i]";

Adds a parameter to limit the number of words in the titles with a trailing syntax of your choice for titles that exceed this length, so your parameter array and associated tag would look like this:

<?php
    $wtl[
'show_date'] = "no";
    
$wtl['date_fmt'] = "M d, Y";
    
$wtl['limit'] = "6";
    
$wtl['offset'] = "0";
    
$wtl['orderby'] = "recent";
    
$wtl['weblog'] = "news";
    
$wtl['category'] = "";
    
$wtl['page'] = "comments";
    
[i]$wtl['words'] = "3";[/i]
        [i]$wtl[
'trail'] = "...";[/i]
?>

<?php weblog_title_list
($wtl); ?>

An example of this hack can be seen at Archinect.com (the 6 most recent entries from 4 different sections, at the bottom of the page).  These are set to show 6 entries, with a word limit of 3.  They are all showing the newest entries except for the discussions which is showing the 6 most recently commented discussions.

To create this hack open archives.fns.php and do the following:

- goto function weblog_title_list($wtl=”“) and add the following arrays:

(is_array($wtl) AND isset($wtl['words'])) ? $words = $wtl['words'] : $words = "";
    
    (
is_array($wtl) AND isset($wtl['trail'])) ? $trail = $wtl['trail'] : $trail = "";

- find this code (around line 190):

echo "<a href=\"$ppath". $wpath ."\">".$title."</a>";
        
        if (
$date == "yes" || $date == "")
        
{
            
echo "&nbsp; " . date($date_fmt, $t_stamp) . "<br />\r\n";
        
}
        
else
        
{
            
echo "<br />\r\n";
        
}

and replace with this code:

echo "<a href=\"$ppath". $wpath ."\">";
        
        
$elements = explode(" ",$title);
        for (
$i=0;$i<$words;$i++)
        
{
            
echo " $elements[$i]";
        
}
        
        
if (count($elements) > $words)
        
{
            
echo "$trail";
        
}
        
if ($date == "yes" || $date == "")
        
{
            
echo "&nbsp; " . date($date_fmt, $t_stamp) . "<br />\r\n";
        
}
        
else
        
{
            
echo "</a><br />\r\n";
        
}

And that’s it.  To show your weblog titles on your website, place the following code in your regular pmachine template:

<?php
    $wtl[
'show_date'] = "no";
    
$wtl['date_fmt'] = "M d, Y";
    
$wtl['limit'] = "6";
    
$wtl['offset'] = "0";
    
$wtl['orderby'] = "[b]recent[/b]";
    
$wtl['weblog'] = "news";
    
$wtl['category'] = "";
    
$wtl['page'] = "comments";
    
[b]$wtl['words'] = "3";[/b]
        [b]$wtl[
'trail'] = "...";[/b]
?>

<?php weblog_title_list
($wtl); ?>

I’m a complete newbie at php so I won’t be able to provide any support with this hack.  I also cannot guarantee the reliability or efficiency of this code

Profile
 
 
Posted: 13 December 2004 02:02 AM   [ Ignore ]   [ # 1 ]  
Summer Student
Total Posts:  29
Joined  2002-11-06

I need some help.  I’ve implemented this hack but I think it’s missing the function to list the weblog titles by latest comments,  $wtl[‘orderby’] = “recent”;

I don’t see this in the archives.fns.php hack.  Can someone help me?

Profile
 
 
Posted: 13 December 2004 09:13 AM   [ Ignore ]   [ # 2 ]  
Grad Student
Avatar
Rank
Total Posts:  78
Joined  2002-06-01

you should have the following array under function weblog_title_list($wtl=”“)

(is_array($wtl) AND isset($wtl['orderby'])) ? $orderby = $wtl['orderby'] : $orderby = "";

also, at around line 127 you should have the following code:

switch ($orderby)
    
{
        
case ""      : $q .= " order by t_stamp desc";
        break;
        case
"recent": $q .= " order by c_date desc";
        break;
        case
"newest": $q .= " order by t_stamp desc";
        break;
        case
"oldest": $q .= " order by t_stamp asc";
        break;
        case
"alpha" : $q .= " order by title asc";
        break;
        default      :
$q .= " order by t_stamp desc";
        break;
    
}

you may be working with an outdated version of this file.

Profile
 
 
   
 
 
Post Marker Legend
New Topic New posts Hot Topic Hot Topic with new posts New Poll New Poll Moved Topic Moved Topic Sticky Topic Sticky topic
Old Topic No new posts Hot Old Topic Hot Topic with no new posts Old Poll Old Poll Closed Topic Closed Topic Announcement Announcements
Theme
Change Theme
Visitor Statistics
The most visitors ever was 233, on December 18, 2007 12:04 AM
Total Registered Members: 64970 Total Logged-in Users: 0
Total Topics: 81991 Total Anonymous Users: 0
Total Replies: 440695 Total Guests: 13
Total Posts: 522686    
Members ( View Memberlist )
Active Members: