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"> </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"> </div>
</div>
Sorry, i should mention that
Sorry, i should mention that code above is in the contemplate module.
I have experienced the same
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!
Hmm this is quite annoying!
I have found the Drupal
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.
mine to.. oh well.
This is not a trivial
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
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?
...
*shrug*
EDIT - I had to remove my
EDIT - I had to remove my non-constructive comment.
try putting your contemplate code in a tpl file
create a file called node-your_content_type.tpl.php in your theme directory put your contemplate code there.
Try viewing the source code
Try viewing the source code of your website. See if
base_pathorpath_to_themeprints any output.Secondly, where did you place this template file?
-----
Drupal theming services, PSD to Drupal
http://kahthong.com
...
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.
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.phpfiles 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.phpand 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.
Taken from your comment above.
-----
Drupal theming services, PSD to Drupal
http://kahthong.com