User:mikelietz

From Habari Project

Jump to: navigation, search

Plugin developer, (Occasionally) troublesome user, likes lurking in the IRC channel. Unsuccessfully ported a custom Wordpress theme to Habari, never to be released.

Twitter: twitter.com/mikelietz

Website: mikelietz.org

sandbox:

Contents

ACL discussions

http://groups.google.com/group/habari-dev/browse_thread/thread/5f7b13689e777c14/ab9f362878c25dd6?lnk=gst&q=acl#ab9f362878c25dd6 http://groups.google.com/group/habari-dev/browse_thread/thread/fce60fc7c6c5e435/19ac2fbb60294e80?lnk=gst&q=acl#


$Request display content

These are the possible display methods(? attributes?) for a $request object (plus any added through rewrite rules):

  • display_home
  • display_entries
  • display_entries_by_date
  • display_entries_by_tag
  • display_entry
  • display_page
  • display_search
  • display_404

In the example below I only want to display the search form when I am not displaying the search results page(s).

<?php if( !($request->display_search ) ) { ?>
 
<li id="search">
<?php include 'searchform.php'; ?>
</li>
 
<?php } ?>


Friendlier ordinal comments links

"Friendlier" only in English, that is.

<?
        // pointless and dirty hack.
        $ordinals = array("no","one","two"); ?>
 
<div class="feedback">
        <a href="<?php echo $post->permalink; ?>" title="Comments on this post"><?
 
        echo ($post->comments->approved->count >= count($ordinals) ? $post->comments->approved->count : $ordinals[$post->comments->approved->count ] );
        echo _n( ' comment', ' comments', $post->comments->approved->count );
 
        ?></a>

Counting words in a post

Not counting the title, though:

<? echo count( explode( " ", strip_tags( $post->content_out ) ) ); ?> words.

This is the basis of my word count plugins.

XHTML to HTML

Wow. Amazingly easy way to fix all of the horizontal rules:

UPDATE habari__posts SET content=REPLACE(content,'hr /','hr');

Pulling out the most recent entry outside of Habari

$conn = mysql_connect($host,$user,$password) or die ('Connection failed');
        mysql_select_db( $db );
 
        $query = "SELECT * FROM habari__posts where id = (SELECT max(id) 
                FROM habari__posts WHERE content_type = '1' and status = '2')";
 
        $result = mysql_query($query);
 
        while($row = mysql_fetch_array($result, MYSQL_ASSOC)) {
                $date = date("j F Y",strtotime($row['pubdate']));
                $title = $row['title'];
                $content = wpautop($row['content']);
        }
        mysql_close( $conn );
Personal tools