Path to theme in contemplate

stephtek - December 12, 2008 - 17:50

For some reason pathing to my theme folder to access an image using <img src="<?php print base_path() . path_to_theme() . "/images/arrow-sm.gif"; ?>" alt="Arrow" width="12" height="15" border="0"/> is not working?

Is there some kind of specific code I am missing?

<div class="box">
<div class="right-box-third-top">&nbsp;</div>
    <div class="right-box-third-middle">
<div class="featured-img"><?php print $node->field_featured_img[0]['view'] ?></div>

<div class="more-info"><a href="<?php print $node->path ?>" title="<?php print $title ?>">More Info <img src="<?php print base_path() . path_to_theme() . "/images/arrow-sm.gif"; ?>" alt="Arrow" width="12" height="15" border="0"/></a></div><h1><a href="<?php print $node->path ?>" title="<?php print $title ?>"><?php print $title ?></a></h1>

<?php print $node->content['body']['#value'] ?></div>
    <div class="right-box-third-bottom">&nbsp;</div>
</div>

Sorry, i should mention that

stephtek - December 12, 2008 - 18:04

Sorry, i should mention that code above is in the contemplate module.

I have experienced the same

DirtyBirdNJ - December 12, 2008 - 20:14

I have experienced the same problem. The way (terribly inelegant and *NOT* the right way) that I overcame it was by hard-coding the URL to the image. I could not find a better way to do it. No combination of the two functions you mentioned would work for me either.

Hmm this is quite annoying!

stephtek - December 12, 2008 - 21:53

Hmm this is quite annoying!

I have found the Drupal

DirtyBirdNJ - December 17, 2008 - 16:52

I have found the Drupal community can either be VERY helpful or... well... I think this thread exemplifies the Drupal forum support experience perfectly.

Simple question, not clearly explained in any documentation, and not a single person who understands what's going on can be bothered to help.

My image links are still hard-coded... sigh...

mine to.. oh well.

stephtek - December 17, 2008 - 20:03

mine to.. oh well.

This is not a trivial

Jeff Burnz - December 18, 2008 - 12:47

This is not a trivial question ok, and bashing the help won't make them work harder either. I would stongly suggest that you ask in the contemplate issue queue - this is a very specific issue/question and quite possibly only regular users or the developer might now the answer.

Have you read this - http://drupal.org/node/194098 , in particular comments #38 & 39

What about the API docs - have you read those, afaikt calling path_to_theme() is highly likely to be problematic in this case and is probably either empty or returning the wrong path.

The OP does not provide any output of this code, so we cant even see what its generating - this assumes we have either flat out know the answer (not likely since this is an edge case) or are prepared to take the time to replicate this AND debug it.

Please keep on-topic, your post is rather pointless and does not actually offer any help.

Ok, the problem is

DirtyBirdNJ - December 18, 2008 - 17:32

Ok, the problem is non-trivial. To a drupal newbie (like myself), more things than not are non-trivial (like trying to understand the API docs).

Both of us are trying to link to images that are stored in custom themes.

What is the correct way to link to images in a custom theme, without hardcoding the image url?

...

Jeff Burnz - December 18, 2008 - 17:40

*shrug*

EDIT - I had to remove my

DirtyBirdNJ - December 18, 2008 - 17:45

EDIT - I had to remove my non-constructive comment.

try putting your contemplate code in a tpl file

travisc - January 7, 2009 - 12:07

create a file called node-your_content_type.tpl.php in your theme directory put your contemplate code there.

Try viewing the source code

ktleow - January 7, 2009 - 13:44

Try viewing the source code of your website. See if base_path or path_to_theme prints any output.

Secondly, where did you place this template file?

-----
Drupal theming services, PSD to Drupal
http://kahthong.com

...

Jeff Burnz - January 7, 2009 - 22:11

Astounding - you claim to offer Drupal theming services yet fail to know the difference between contemplate module ("templates" are saved in the database) and standard drupal theme templates?

Need help with IE?
Learn basic XHTML and CSS first.
Get Firebug.

You're not completely right.

ktleow - January 8, 2009 - 01:30

You're not completely right. Do not simply shoot people before knowing things correctly.

Contemplate allows you to place physical file in your themes directory or in sites/all/contemplates.
Read up their documentation.

Basically, when you already have these *.tpl.php files saved, you can optionally remove Contemplate too (this module only serves as a helper for you to get the variables of your nodes printed).

If you do not want to use Contemplate, simply create node-*.tpl.php and place the following code inside:
<?php print_r($node); ?>

Get it now? We here are trying to help you guys out. Yet you're acting as if we're wasting our time.
So, I was just trying to make things clear before concluding something.

If you do not wish to help, then don't.

.. bashing the help won't make them work harder either ..
Please keep on-topic, your post is rather pointless and does not actually offer any help.

Taken from your comment above.

-----
Drupal theming services, PSD to Drupal
http://kahthong.com

 
 

Drupal is a registered trademark of Dries Buytaert.