Jump to content

Recommended Posts

Posted

Hello everyone,

I've just finished building a small website based on the default profile's structure but with this as a "profile": http://purecss.io/layouts/side-menu/

Logo ("/header/") is a hidden page with just a "PageTitle" field, an "Image" field and a "Text" field.

So, I have this in _init.php:

$logo = $pages->get('/header/')->images->first();

And this in _main.php:

<img src="<?=$logo->url?>" width="<?=$logo->width?>" height="<?=$logo->height?>" alt="<?=$logo->description?>" />

But, via Firebug or the default web developer tools of different browsers, the "description" part doesn't appear in alt:

In Firefox:

<img width="98" height="129" alt="" src="/site/assets/files/1036/psi_alphabet_grec_ipsyus-1.png">

In Chromium/Chrome and Opera:

<img src="/site/assets/files/1036/psi_alphabet_grec_ipsyus-1.png" width="98" height="129" alt="">

I've also tried with the following variation in _init.php, but it doesn't change anything:

$logo = $pages->get('/header/, include=hidden')->images->first();

The content of the alt attribute (that is to say the content of "Description" in the "Image" type field) is only displayed when I am logged in as a superuser or as a simple user with less permissions/rights.

I have some "intuitions", but not more for the moment.

Any ideas :)?

Posted

Please have a look a the actual source-code and not the dom representation of the devtools. They sometimes hide things all together if there's a issue with parsing. 

The "include=hidden" selector shouldn't matter, as it's only part of getting the page. If your image is shown, then your selector is working. 

With you stating that it works for logged-in users, could you please post what this shows you if you're not logged in?

var_dump($logo->description);

Also please make sure $config->debug is enabled, so errors are shown.

  • Like 2
Posted

Hello LostKobrakai,

In this case at least, I've also looked at the source code.

As the image and its width and height are displayed without include=hidden, I was just curious to see if it could change something.

$config->debug is already enabled, but I haven't really looked at the information it displays in the backend.

So, I've replaced

alt="<?=$logo->description?>"

with

alt="<?=var_dump($logo->description)?>"

and I have:

  • <img width="98" height="129" "="" alt="string(0) " src="/site/assets/files/1036/psi_alphabet_grec_ipsyus-1.png">
     in Firebug;
  • <img src="/site/assets/files/1036/psi_alphabet_grec_ipsyus-1.png" width="98" height="129" alt="string(0) ""
    " /> 

    in the source code.

Where did I have to put var_dump($logo->description);?

# When logged in as superadmin, or as the simple user, there is

<img width="98" height="129" "="" ipsyus"="" -="" grec="" alphabet="" en="" psi="" alt="string(29) " src="/site/assets/files/1036/psi_alphabet_grec_ipsyus-1.png">

in Firebug,

and

<img src="/site/assets/files/1036/psi_alphabet_grec_ipsyus-1.png" width="98" height="129" alt="string(29) "psi en alphabet grec - ipsyus"
" />

in the source code.

Posted

Perhaps you have php short tags disabled? Try using "<?php echo $logo->url; ?>" instead of "<?=$logo->url?>" (and everywhere else).

Posted

You should best put this not in a php shortcode and not in a attribute. This way you'll just see the text in your website.

<pre><?php var_dump($logo->description); ?></pre><img… />

But the information is still there. It's an empty string ( string(0) ) as long as you're not logged-in, which is quite strange. Could you please post which version of ProcessWire you're using and if there are any 3rd party modules installed?


Perhaps you have php short tags disabled? Try using "<?php echo $logo->url; ?>" instead of "<?=$logo->url?>" (and everywhere else).

Then nothing would be outputted and not only the description missing.

Posted

ProcessWire 2.5.3 © 2015

Default language + French language (for the simple user at least)

Site modules installed and activated (for the moment):

  • Email -> Email Obfuscation (EMO)     1.0.3
  • Fieldtype -> Map Marker     2.0.6
  • Inputfield -> Map Marker     2.0.7
  • Markup -> Map Markup (Google Maps)     1.0.1
  • Process -> Redirects     1.0.0
Posted
Then nothing would be outputted and not only the description missing.

Yep, false positive :)

I guess it's something with the default language then.

Posted

No clues?

I tried different things but it didn't change anything.

It could be a permission issue of course, but why?

I could just hard code it, but I'd like to understand why this happens.

Posted

Have you set the description field for all languages?

What is the default language for Guest users? (Admin - Access - Users - Guest)

  • Like 1
Posted

Hi,

(It's not a multilingual website.)

The mistery is solved. It's quite logical.

The language for Guest was Default. It had to be French to display the description when not logged in.

And the language for the superuser had to be French to display the description when logged in. I often changed the language for the superuser but I didn't notice the difference until now.

The multilingual description is deactivated by default so I hadn't realized that I had completed the "Description" (same label) only when logged in as the superuser with the French language.

I guess that if I had done the opposite it wouldn't have bothered, as the (empty) French description would have inherited from the Default one.

Thanks to both of you for helping me go more precisely in the right direction.

Posted

I thought it was multilanguage site (comment #6) but anyway, glad you sorted this out.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...