By gostram on
Hi all, I have a block displaying a random image from my galleries. I would like the block title to be a link to the main gallery page, and if possible to look exactly like the other block titles (that is, not like a link).
The website is here
The block title (PYRN GALLERY) would lead to the publications/gallery page. Not sure how to do this though.
Comments
I think if you copy your
I think if you copy your theme's block.tpl.php to block-xx.tpl.php, where id is the block's id number, then you can edit that template and it will only be used for that block.
You should find a part in the template something like
and you would need to change the middle line to something like
gpk
----
www.alexoria.co.uk
Thanks a lot gpk, I also
Thanks a lot gpk, I also found this node which seems to be relevant: http://drupal.org/node/74481
The only issue is that I seem to have several blocks with the same number, I guess because of the type of block.
My block's type seems to be "image" and its delta "1"
now do I just create a block-01.tpl.php file with the code, upload it in the theme folder and it will work automatically? how do I take into account the type of block?
Thanks in advance for your answers
The template filename needs
The template filename needs to be block-[module]-[delta].tpl.php
So in your case, block-image-1.tpl.php
IT WORKS!!!!!!!
woaaaaaaaaaaaaah!!!!!! thanks Joachim. That definitely helped. Sometime I wished there'd be more basic explanation like the one you just gave on drupal.org
Most of the time, the stuff I find are "use this code" or "tweak the patch to adjust X to Y". Really hard to understand....
thanks again.
Thanks for setting me right,
Thanks for setting me right, joachim! And for sorting out this page http://drupal.org/node/104319 which describes it all in full (I couldn't find it yesterday - nice job).
gpk
----
www.alexoria.co.uk
gpk
----
www.alexoria.co.uk
If you want to apply this to
If you want to apply this to all blocks, you can create a small modules called say, block_titles, with the following function:
If your worried about security, then you could always define a block_titles_form_block_admin_configure_alter function that altered the block form, allowing users with the right access permission to tick a 'HTML title' tick box, but then you'd need to store these values in a table, and alter the above function to check these values. Not hard, but unnecessary in most cases.
bb code
Here is another approach that I've used: http://drupal.org/node/28537
Phpfreechat Block
Thanks to all who posted here. For newbies like myself, to get the module and delta values, it's less confusing to look at the source if you're logged in as a user, not admin.
I wanted users to be able to click on the "Who is Chatting" block title to join the chat. This has made a world of difference in the number of users chatting.
The block.tpl.php (found in sites/all/themes/(name of the theme) was this:
I viewed the source of a node where the "Who is Chatting" block was active and found the id for this block to be
phpfreechat-0. Then I copiedblock.tpl.php, renaming the copy asblock-phpfreechat-0.tpl.php. It stays in the same directory asblock.tpl.php.Then I edited
block-phpfreechat-0.tpl.phpas follows:<a href="<?php print base_path(); ?>node/4753"><?php print $block->subject ?><br />(Click here to chat)</a>Of course, you'd change
node/4753to the relative link you want.This works just like I wanted it to -- hope this helps someone.
another one
you can also simply change
$block->subject = $block->title == '' ? '' : check_plain($block->title);
to
$block->subject = $block->title == '' ? '' : $block->title;
in modules/block/block.module (although i'd consider this a hack
and prefer the hook solution).
if 64 characters (including the html) are not enough, make it
somewhat bigger in the database, for postgres that is
alter table blocks alter column title type varchar(128)
very useful thank you
i was searching for a way to make a block title link to another page. and this page and the other link http://drupal.org/node/104319 were very helpful.
i just think that there should be an easier way to do this without modifying the code, i mean from the block admin interface, like when configuring a block in the block title field we should be able to add a link there. i hope the next Drupal releases would include this small update in them, i dont know if it's important to others as well but i think it's a very useful feature.
thank you all for your help...
Here is a new module.
If anyone is looking for a module to do this, there's a module now for that.
http://drupal.org/project/block_titlelink
Drupal 5?
What would it take to backport this module to Drupal 5? Would this just work if I just change the version numbers in the .info file, or are there too many changes between 5 and 6 to make it practical? I'm running a website that I can't just upgrade as it uses modules that don't exist in 6 yet.
edit: well, tried doing exactly that on a local copy of the site, and had disastrous results. Seems like the whole i18n system changed between both versions.
Thanks!
Thanks!
this is an
excellent solution!