phpBB3 Topic Tagging

After over 2 years of no development, on what seemed to be an abandoned project that everyone thought was dead, its back. phpBB Topic Tagging

Preview of topic tagging screens

After lot of searching i have managed to resurrect an old mod i created for phpBB that allows users to tag topics. Originally called phpBBFolk (but now a much less cryptic “phpBB Topic Tagging”) it was getting a lot of use by others but something went wrong and it seemed like it was lost forever.

It now has a new home (here) and is hosted on GitHub so that it won’t get lost again and people can easily help improve it.

The original thread for the mod was this topic but this has since been locked, a lot of issues in the later part of the thread are likely to still exist as I dont have time to go back and fix them all, but if people wish to re-post the issues (preferably here) then I’ll be able to get round to them.

So, the mod allows logged in users to tag posts and shows tag clouds on the board, one for the board as a whole and for individual forums which only shows tags in that forum.

Users enter tags by entering the tags at the bottom of the post, their is a suggestions box that auto-completes with tags already in the system, this will reduce the number of duplicate tags that find their way in. Check out the demo to see what it does, you will need to register to use the board.

Download

You can download the mod here or you can clone the project from GitHub

The mod is still in the beta stage so no responsibility is taken if something goes wrong.


Only Showing Content & Comments To Registered Users In WordPress

Recently one of my clients asked if it was possible to only show content to registered users on a WordPress site.

The solution is very simple using WordPress’ filter system.

add_filter("the_content", "block_content" );
add_filter("comment_text", "block_comment");

function block_content($content){
if(!is_user_logged_in()){
return __( ‘You must be logged in to view content’ );
}else{
return $content;
}
}
function block_comment($content){
if(!is_user_logged_in()){
return __( ‘You must be logged in to view comments’ );
}else{
return $content;
}
}

Putting that snippet in your theme’s functions.php file will swap comment, page and post content with the messages above.

WordPress Template is missing

Recently while working on a custom WordPress theme I kept running into the issue where my theme would become unusable and in my Appearance section of the back end I would get the error “Template is missing” for my theme.

Often you get this error when you are trying to inherit from a theme but the theme cannot be found,  in my case my theme wasn’t inheriting from another so I couldn’t work out why I was getting this error.

Eventually after a lot of careful cross checking I figured it out

I had to remove any comments that contained the string “TEMPLATE:”, this may also be caused by the lower case “template:” but I didn’t test this.

I had comments like this in as part of my stylesheet:

/* TEMPLATE: Sidebar content */

This was causing WordPress to look for a theme that didn’t exist.

I assumed that WordPress would only look in the top comment block for the theme information but i was wrong…

Turning CakePHP’s Pagination output to a list

I’ve spent the last few hours investigating how to style the out produced by cakes $paginator helper.

I managed to get a digg style output for my pagination by styling the output produced by default, but because of the number of divs and spans that had to be floated i thought that it would be much easier to style if it were a list.

The default output generated by the Bake scaffolding looks something like this

CakePHP Default Pagination

and the html like

<div class="paging">
<div class="disabled"><< previous</div>
<span class="current">1</span> |
<span><a href="/cakephp/cms/admin/blog/posts/index/page:2">2</a></span> |
<span><a href="/cakephp/cms/admin/blog/posts/index/page:3">3</a></span>
<a href="/cakephp/cms/admin/blog/posts/index/page:2">next >></a>
</div>

This can be quite easily changed to a list output by using the $options parameter of the $paginator->numbers() function.

In your views where you are using pagination find the call to the $paginator->numbers() function. On my 1.2.6 version of CakePHP it looks like this

numbers();?>

Change this to the following

prev(‘<<’.__(‘previous’, true), array(), null, array(‘class’=>‘disabled’));?>
numbers();?>
next(__(‘next’, true).‘ >>’, array(), null, array(‘class’ => ‘disabled’));?>

This will then produce output similar to this (it depends what page your on)

<div class="paging">
<a href="/cakephp/cms/blog/posts/index/page:1"><< previous</a>
<ul class="pagination">
        <li><a href="/cakephp/cms/blog/posts/index/page:1">1</a></li>
        <li class="current">2</li>
        <li><a href="/cakephp/cms/blog/posts/index/page:3">3</a></li>
</ul>
<a href="/cakephp/cms/blog/posts/index/page:3">next >></a>
</div>

To style this digg-stylee you can use the following CSS, just add it to your apps main CSS file.

div.paging a{
border:solid 1px #9aafe5;
margin-right:2px;
display:block;
float:left;
padding:3px 4px;
}
ul.pagination li{
border:0; margin:0; padding:0;
font-size:11px;
list-style:none;
margin-right:2px;
}
ul.pagination a{
border:solid 1px #9aafe5;
margin-right:2px;
display:block;
}
div.paging div.disabled {
border:solid 1px #DEDEDE;
color:#888888;
display:block;
float:left;
font-weight:bold;
margin-right:2px;
padding:3px 4px;
}
ul.pagination .next a,
ul.pagination .previous a {
font-weight:bold;
}
ul.pagination .current{
background:#2e6ab1;
color:#FFFFFF;
font-weight:bold;
display:block;
float:left;
padding:4px 6px;
}
ul.pagination a:link,
ul.pagination a:visited {
color:#0e509e;
display:block;
float:left;
padding:3px 6px;
text-decoration:none;
}
ul.pagination a:hover{
border:solid 1px #0e509e
}

You should then have something that looks like this

CakePHP Style Pagination

And thats it!

Any trouble, leave a comment and we’ll try and sort it out.

The original CSS code for the Digg style links was taken from this post: http://woork.blogspot.com/2008/03/perfect-pagination-style-using-css.html