Hi there,
Brand-new user, PHP newbie. I'm using an installation of Drupal shared with a number of others & must make any design changes via my own specialized theme within my own site folder.
Desired: I want to change the display of the links under blog posts (I'm using the box_grey_smarty theme as my base). It currently displays links to the poster's blog and a link to #comments/add comment. I need it to only display a link to #comments/add comment. Cannot find a toggle anywhere in the configuration, so I'm assuming the change has to be made at the theme level (or above).
Problem: I can't figure out how to change this in my node.tpl theme template without having to change the variable $links, which returns both. But I can't change that, since the variables are defined in a shared file outside my site folder somewhere & I can't disrupt the others' blogs.
(Am I understanding the system correctly?)
Can I make a copy of whatever file defines those variables and put it in my theme folder and drupal will use my more specific instance instead of the common one? Maybe I should just be asking: where is the variable $links defined, and how do I change what it returns?
Thanks & hope this was halfway clear.
Comments
easy
I'm assuming you're using phptemplate.
Copy your node.tpl.php and name is node-blog.tpl.php
Then replace the line that says
<?phpprint $links
?>
<?php
global $user;
if ($user->uid) {
print ('<a href = "/comment/reply/'. print $node->nid. '">add comment</a>');
}
else {
print ('Please log in to post a comment');
}
?>
the first part checks to make sure they are logged in. If they are logged in, it will display the "add comment" link. If they are not logged it, it wll display the "please log in..." text.
I havn't checked this myself, and my php is a little rusty, but I'm pretty certain it will work.
I have a similar setup on my website for my forums.
Thank you, Mateo, that's
Thank you, Mateo, that's exactly what I was looking for. Alas, I'm not using PHPTemplate (couldn't get it to work on our site) but Smarty, so the tags are all different, but now that I know the correct PHP snippet I can probably muddle through it. Very kind of you, thanks!
A different way to approach this
It sounds like you are the only blogger on your Drupal site, is that right? (Not talking about other sites that share the Drupal installation, but just your own site.)
If you are, you might try using the story module instead of the blog module. I think the story module is better suited for a single user blog--the blog module is really designed for a multiuser blog (thus the "Jack's blog" and "Jill's blog" links).
Thank you, Geary, I'll
Thank you, Geary, I'll definitely check that out. First time I've used Drupal and am used to WordPress et al.
Glad to help
Interestingly enough, the reason I suggested this was because I was thinking about converting my WordPress blog to Drupal. (I'm tempted to use Typo instead, but I'm not sure.)
In the Drupal sites I've set up so far, I've used the blog module for blogs. (Kind of a no-brainer, right?) But when I ran Sam Revitch's WordPress-to-Drupal conversion script, I noticed that it used the story module instead of the blog module.
That seemed odd, so I changed it to use the blog module. But then I saw what Sam was doing---the story module made it look and work more like a WordPress blog, without the "Mike's blog" links and /blog/michael-geary page they point to. For a single-user blog, that page just duplicates the main page. It only makes sense when you have multiple bloggers; they can each have their own individual blog pages, with the home page and /blog pages serving as aggregators.
Since mg.to is strictly my personal blog and I don't plan to add other authors, I'll probably use the story module if I do go with Drupal.
OTOH, If I had any plans of opening up the site for other authors, I'd use the blog module instead. In that case I'd use Mateo's trick to suppress the "Mike's blog" links if I'm the only blogger at first.
You can still use story
You can still use story, or page even.
If you add new authors, just add a category vocabulary called "blogs", then add each author as a term in that category. All the authors have to do is pick their name from the list.
Then you can use something like site menu or taxonomy menu to give you a side menu with the categories and terms, as well as a site map too.
Another (potentially risky) way to do it is to reclassify the nodes from 'story' to 'blog' in the database, since there does not seem to be data storage associated with blogs.
--
Drupal development and customization: 2bits.com
Personal: Baheyeldin.com
--
Drupal performance tuning, development, customization and consulting: 2bits.com, Inc.
Personal blog: Baheyeldin.com.