I'm trying to make flag images instead of text i've done everything that was suggested by the flag's documentation the images are showing in the teasers but in the node page it doesn't show saw on on firebug that the image link was ok but it doesn't show i'm using drupal 6.9 and flag 6.x-1.0-beta6

Comments

quicksketch’s picture

Category: bug » support
Priority: Critical » Normal

We'll need more information to help with your request. What CSS did you use to add the images (and in which file)? If it's working on teasers but not on the node page, my guess is that the CSS file you're using isn't being added to the page.

youkho’s picture

Place this function as recommanded on the documentation page

function phptemplate_preprocess_flag(&$vars) {
$image_file = path_to_theme() . '/flag-' . $vars['flag_name_css'] . '-' . ($vars['action'] == 'flag' ? 'off' : 'on') . '.png';
// Uncomment the following line when debugging.
// drupal_set_message("Flag is looking for '$image_file'...");
if (file_exists($image_file)) {
$vars['link_text'] = "Only local images are allowed.";
}
}

then placed my template flag-recommand.tpl (exact copy of flag.tpl) in my theme's folder and the images too (flag-recommand-on.png & flag-recommand-off.png) as i said everything works fine in the teaser but in the node's page the image is missing

right now there's no CSS for the flags

mooffie’s picture

(He's using the recipe shown at "How to show images instead of text". I think I see the problem.)

Youness,

Right now your URL looks like "http://example.com/node/23". Change it to "http://example.com?q=node/23". Does this make the images appear?

youkho’s picture

Hi moofie,

Since i'm using the clean urls and pathauto my url is (http://localhost/mooroki/news/obama-bin-laden-error-hits-yahoos-homepage...) changed to mooroki?q=node/31 same problem no image is shown i think i'll consider the CSS method and hope this issue will be fixed

mooffie’s picture

Status: Active » Fixed

Youness, I believe I fixed the code in that handbook page (I prefixed the image URLs with base_path()).

youkho’s picture

Yeah since no one reported the same issue maybe there's something wrong on my code thanks anyway

mooffie’s picture

Yeah since no one reported the same issue maybe there's something wrong on my code thanks anyway

There was a bug in the code in that handbook page and I have fixed it.

If the new code still doesn't work for you, do "View Source" in your browser, locate the IMG tag, and paste its content here so we can inspect the image URL.

youkho’s picture

Ah ok will do that asap and report back the result

mooffie’s picture

Youness, it might help you to know that the line that had the bug was this one:

$vars['link_text'] = "<img src='$image_file' />";

I changed it to:

$vars['link_text'] = '<img src="' . base_path() . $image_file . '" />';

So if it's easier for you, you can replace only this one line.

Again: if that doesn't solve your problem, paste here the IMG tags generated so we can try to figure out what's wrong.

youkho’s picture

Hello moofie,

Don't know what happened but when i upgraded to the latest version 6.x-1.0-rc1 lost of even the flag's counts used print $flag->get_count($content_id); in flag-recommand.tpl and the images aren't showing this time not even in the teasers should i downgrade ?

mooffie’s picture

i upgraded to the latest version 6.x-1.0-rc1 [...]
in flag-recommand.tpl and [...]

The latest version switched to use two dashes in the tempalte file-names.

In other words, you need to rename "flag-recommand.tpl" to "flag--recommand.tpl". And make sure to clear Drpual's cache or it won't notice this new file.

And note that computers aren't human. If you named your flag "recommend", with "e", don't expect Drupal to forgive you for spelling it with "a" in the template filename.

mooffie’s picture

and the images aren't showing this time not even in the teasers

"images aren't showing" isn't helpful. Either the image URLs are bad, or the custom code didn't kick in at all. To find which of the two possibilities it is, inspect the HTML and see if the IMG tags are there.

youkho’s picture

Now it's fixed changed to the two dashes cleared the cache and everything works now as it should be.

ps : i know it's not the place for this kind of questions but i don't want to open a new issue ^^ it's like the Ajax reloading function isn't working even if the link type is javascript toggle when i click it's seems like reloading the whole page.

Thank you so much mooffie appreciate your help :)

mooffie’s picture

the Ajax reloading function isn't working [...] seems like reloading the whole page.

So it doesn't work for the "recommend" links. But does it work for other flags? In other words, perhaps the fault is somewhere in your altered "flag--recommand.tpl" file. Delete this file (of course, save it first somewhere), clear Drupal's cache, and see if the AJAX now works.

Is your site on a public-accessible server where I can see the problem?

youkho’s picture

Ok now that i've tested the default flag template it's working since the code changed with the new version i had to update my template too to make the ajax work with the " print $flag->get_count($content_id); "

in line 44 in the new version 6.x-1.0-rc1 there's no echo $action;

So it was a little bit my fault xD thanks a lot mooffie without you couldn't make it work ;)

mooffie’s picture

in line 44 in the new version 6.x-1.0-rc1 there's no

echo $action;

Thanks for bringing this to our attention. (This will be dealt with in another issue.)

youkho’s picture

Okay i'll help testing

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.