php problem on SPPB4 override article addon - Forum | JoomShaper
Solved SP Page Builder

php problem on SPPB4 override article addon

Asked by Fabrice 3 years ago Last activity 3 years ago

Hi, I'm on SPPB4, template Maestro.
I created an overide for sppsagebuilder/addons/articles/site.php
I have to use the image into a
$output .='<div style="background-image: url("./'.$mythumbnail.'");">ABWW</div>';
My url is l'url /demo3/images/2022/12/30/XXX.jpg
When I get on the site page, the code turns into "<div style="background-image: url(" .="" demo3="" images="" 2022="" 12="" 30="" XXX.jpg");"="">
What can I do ?

ps ; I was simply hoping
$output .='<div style="background-image: url("' . ($default_placeholder && $page_view_name != 'form' ? $default_placeholder : $image) . '");">ABWW</div>'; could possibly do it but it didn't.

Accepted answer

Marked as the solution
Fabrice Asked this
3 years ago · edited

Wow, my apologies on this one... After reviewing this thing fo the millionth time, I realized I misspelled and forgot a couple of ' ' ...
$myDiv='<div align=center id="background" style="background-image: url(\''.$mythumbnail.'\');">DDD</div>';
In case that can help anyone in the future...

9 more replies

Fabrice Asked this
3 years ago · edited

... seems that your system reformulates the variables...
If I feed it with $mythumbnail="AAAA"; uppercase
it sends me back "aaaa"... lowercase
So Is there a piece of code to tell it to leave that thing alone?

Fabrice Asked this
3 years ago · edited

Anyone at all ??? Maybe my description is not clear. Please let me know if you don't understand my concern.

Ofi Khan Staff

Hello Fabrice

Please share a screenshot of your issue to understand it better. Take a screenshot and share via any platform. For example: Lightshot or Imgur. Also, share the page link so that I can check the issue.

Best regards

Fabrice Asked this

ok, let me resume :
I overrode the sppsagebuilder/addons/articles/site.php so I can have a <div> with a css background-image so I can control the size of the image no matter what image size the final admin is going to feed in.
So line 267 -> 270.
The public page gives me the correct info aka "./demo3/images/2022/12/30/glisse_academy.jpg" on page header with my echo.
When I feed the same variable in my css background-image, the public page gives a url that is completely off and seems to treat the info as an array.

https://imgur.com/a/uZIubuz

I'm wasting an insame amount of time on such a strange behaviour.
Why can't I just use the '($default_placeholder && $page_view_name != 'form' ? $default_placeholder : $image)' such as line 272 which is sending me the same array result.

Ofi Khan Staff

Sorry, we do not provide customization support. I think you need to consult a developer for this. It is your code and your responsibility.

Fabrice Asked this
3 years ago · edited
Pavel

Hi Fabrice.

I overrode the sppsagebuilder/addons/articles/site.php so I can have a <div> with a css background-image so I can control the size of the image no matter what image size the final admin is going to feed in.

Just to let you know. For these purposes, you can use CSS only object-fit: cover; for example. Not need php override

Fabrice Asked this

Hi, my apologies on this one, the whole issue was a misspelling...
In the end , works better with the background-image: url(\'...\')...
$output .='<div align=center style="background-image: url(\''.$item->image_thumbnail.'\'); height:250px; background-size: cover; background-position: center;"></div>';
Sorry guys, thanks for your patience.

Ofi Khan Staff

You are welcome 😊

Please accept the answer that helped you. It will be then easier to find the solution for the other users with the same issue. There is a button to accept answer after each comment.

Log in to reply.