base path question

Events happening in the community are now at Drupal community events on www.drupal.org.
nicktr's picture

I'm displaying a block with an image throughout my site, however, on certain pages, the image doesn't display.
I figured out that this is because the path is changed for clean url's so '/content/' is added to urls for things like 'about' pages and other nodes on the site

I think I need to use the base_path() function to solve this but i'm not quite sure how to use it.

The link i need to change is:

<a href="node/add/item-request"><img src="sites/default/files/headerbanner/request-item-button.png"></a>

How would I use base_path()? to solve this issue?

Thanks,

Nick

Comments

you need to use <?php echo

joetsuihk's picture

you need to use

<?php
echo nase_path();
?>

or, javascript have base_path in: Drupal.settings.basePath

Worked perfectly! Thanks

nicktr's picture

Worked perfectly!

Thanks Joe.

Nick.

For an editable block it's

dalin's picture

For an editable block it's best not to use PHP or JavaScript (stability, security, performance, and maintainability issues). Better just to use an absolute path:

<a href="/content/node/add/item-request"><img src="/content/sites/default/files/headerbanner/request-item-button.png"></a>

If what you are trying to do cannot be done without PHP or JavaScript I'd recommend writing up a custom module and implementing hook_block_info() and hook_block_view().

--


Dave Hansen-Lange
Director of Technical Strategy, Advomatic.com
Pronouns: he/him/his

Agree with Dave. It's never a

jdidelet's picture

Agree with Dave. It's never a good choice to store php or javascript code in the database.


Julien Didelet
Founder
Weblaa.com

DrupalHK

Group categories

HKDUG Vocabulary

Group notifications

This group offers an RSS feed. Or subscribe to these personalized, sitewide feeds:

Hot content this week