Jump to content

New Blog Site Profile - how get image-url of child page thumbnail


MarcU
 Share

Recommended Posts

Hi, I'm sort of an intermediate beginner but already quite familiar with PW for a year or so. Now I'm trying to modify the new blog site profile which I find great and quite intuitive (thanks alot Ryan and crew!). I am seeking help for this problem:

I want is to display a thumbnail image for every item of the description list navigation which is part of the basic page template, seen at the bottom of the about-page in the live demo here. The regarding function in _uikit.php is  ukDescriptionListPages on Line 588 which is called with ukDescriptionListPages(page()->children) by the basic page template.

here, in Line 612 in ukDescriptionListPages I inserted this (in red):

$dt = "<a href='$item->url'><img src='$item->thumbnail->url'></a>"."<a href='$item->url'>$dt</a>";       (where "thumbnail" is the name of my new thumbnail field in the basic page template. I limited my thumbnail field to one single image).

But this only gives me back the name of my thumbnail image file, followed by the string "->url" - but not the path to the image. How do I get the full path / url?

Whats wrong with my code? I admit I do not fully understand all of the details in ukDescriptionListPages-function and the also involved ukMergeOptions. I suspect I would somehow have to iterate through the images of my thumbnail field since it potentially could contain more than one image (or at least use thumbnail->first->url which doesn't work in the above setting either), but how and where? Or do I have to add some argument when calling ukDescriptionListPages? It would be great to have a built-in "show thumbnail - yes or no"-option in ukDescriptionListPages in the future.

Thanks in advance for any help!

Markus

  • Like 1
Link to comment
Share on other sites

You just need to add curly braces around the thumbnail url variable:

$dt = "<a href='$item->url'><img src='{$item->thumbnail->url}'></a>"."<a href='$item->url'>$dt</a>"; 

Using curly braces around variables tells PHP exactly where the start and the end of the variable name is, so it doesn't get confused with other neighbouring text that isn't part of the variable name. You can use curly braces around any variable and it wont hurt, but usually isn't necessary until you use more than one -> in your variable or have some other complex variable expression. That's why you get the problem with $item->thumbnail->url but not $item->url.

  • Like 4
Link to comment
Share on other sites

Thanks alot Robin for your fast and simple answer. Works perfect now. The only thing remaining is a debug-message: Notice: Trying to get property of non-object in   .../site/templates/_uikit.php on line 612 which I do not understand - can anybody explain this? It doesn't bother me since I can switch off debug mode to make it disapear but maybe it would be better to fix it.

  • Like 1
Link to comment
Share on other sites

  • 1 year later...

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
 Share

×
×
  • Create New...