11
alain01
Re: Overload the images on the search.php page
  • 2021/10/20 13:57

  • alain01

  • Just can't stay away

  • Posts: 528

  • Since: 2003/6/20


Quote:

zyspec wrote:
The file you're checking for must be a path, not a URL. So chaine_surcharge should be something like:
/var/www/html/themes/mx-theme/modules/xmnews/assets/images/xmnews_search.png

use something like XOOPS_PATH, not XOOPS_URL to build the file location.

HAAAAAaaaaaa,
ok
because I tried without "http" like "xoops-tests2.local/themes/mx-theme/modules/xmnews/assets/images/xmnews_search.png" and it didn't work.
It was URL, without http: protocol but URL.

Ok, I will check (tonight) with the path:
d/web/projets-test/xoops-tests2.local/themes/mx-theme/modules/xmnews/assets/images/xmnews_search.png

Thank you for this detail.

12
Mamba
Re: Overload the images on the search.php page
  • 2021/10/20 14:21

  • Mamba

  • Moderator

  • Posts: 11366

  • Since: 2004/4/23


The result of the code I shared earlier...
Resized Image
Support XOOPS => DONATE
Use 2.5.10 | Docs | Modules | Bugs

13
alain01
Re: Overload the images on the search.php page
  • 2021/10/20 14:35

  • alain01

  • Just can't stay away

  • Posts: 528

  • Since: 2003/6/20


ok ! Cool.
Here with the wrong code :

Profile module
https://www.monxoops.fr/modules/profile/userinfo.php?uid=2

Search page
https://www.monxoops.fr/search.php?query=xswatch4&action=results&lang=english

When all will be ok, I will propose my templates.

14
alain01
Re: Overload the images on the search.php page
  • 2021/10/20 22:35

  • alain01

  • Just can't stay away

  • Posts: 528

  • Since: 2003/6/20


Quote:
Mamba wrote:
<{foreach item=data from=$search.module_data}>
<{*----------- new 
code start -------------*}>
            <{
assign var="module_name" value=$search.module_name|lower}>
            <{
assign var="image" value="themes/xbootstrap/modules/$module_name/images/search.png"}>

No !
Cause the module_name is the label name and not the module name.

Example ?
module xmnews
Name : xmnews
label : The articles

15
alain01
Re: Overload the images on the search.php page
  • 2021/10/21 0:38

  • alain01

  • Just can't stay away

  • Posts: 528

  • Since: 2003/6/20


Yesssssssssssssssssssss ยง
I found it !

Thank you zyspec for your explanation and Mamba for your examples and links.

I found a solution with paramaters, no hard coded.
It was hard for me but it works.
Code :

<{foreach item=data from=$search.module_data}>

    <{
assign var="url_image_overloaded" value=$xoops_imageurl|cat:$data.image_link}>
    <{
assign var="path_image_begin_overloaded" value=$xoops_rootpath|cat:"/themes/"|cat:$xoops_theme}>
    <{
assign var="path_image_full_overloaded" value=$path_image_begin_overloaded|cat:"/"|cat:$data.image_link}>

    <{if 
file_exists($path_image_full_overloaded)}>
        <
img src="<{$url_image_overloaded}>" alt="<{$data.image_title}>"title="<{$data.image_title}>"> <a href="<{$data.link}>"><{$data.link_title}></a>
    <{else}>
        <
img src="<{$data.image_link}>" title="<{$data.image_title}>" alt="<{$data.image_title}>"/> <a href="<{$data.link}>"><{$data.link_title}></a>
    <{/if}>
    <
br />
<{/foreach}>

16
Mamba
Re: Overload the images on the search.php page
  • 2021/10/21 1:24

  • Mamba

  • Moderator

  • Posts: 11366

  • Since: 2004/4/23


Congratulations!!!

I glad to hear that it all worked out for you!!!
Support XOOPS => DONATE
Use 2.5.10 | Docs | Modules | Bugs

17
alain01
Re: Overload the images on the search.php page
  • 2021/10/21 6:58

  • alain01

  • Just can't stay away

  • Posts: 528

  • Since: 2003/6/20


Ok,
So, last question

The result is same but I want to know if a solution is better:

Readable test:
<{if file_exists($path_image_full_overloaded)}>
    <
div class="d-inline"><img src="<{$url_image_overloaded}>" title="<{$data.image_title}>" alt="<{$data.image_title}>"/> <a href="<{$data.link}>"><{$data.link_title}></a></div>
 <{else}>
    <
div class="d-inline"><img src="<{$data.image_link}>" title="<{$data.image_title}>" alt="<{$data.image_title}>"/> <a href="<{$data.link}>"><{$data.link_title}></a></div>
<{/if}>

or
Condensed test :
<div class="d-inline">
    <
img src=<{if file_exists($path_image_full_overloaded)}>"<{$url_image_overloaded}>"<{else}>"<{$data.image_link}>"<{/if}> title="<{$data.image_title}>" alt="<{$data.image_title}>"/> <a href="<{$data.link}>"><{$data.link_title}></a>
    </
div>

18
Mamba
Re: Overload the images on the search.php page
  • 2021/10/21 7:33

  • Mamba

  • Moderator

  • Posts: 11366

  • Since: 2004/4/23


Always choose readability!!!

Or you will come back few months later and will waste a lot of time trying to understand what you've written!
Support XOOPS => DONATE
Use 2.5.10 | Docs | Modules | Bugs

19
alain01
Re: Overload the images on the search.php page
  • 2021/10/21 7:37

  • alain01

  • Just can't stay away

  • Posts: 528

  • Since: 2003/6/20


Ok, so much the better, this solution was my preference.
Thank you for this information on good practices

Login

Who's Online

178 user(s) are online (62 user(s) are browsing Support Forums)


Members: 0


Guests: 178


more...

Donat-O-Meter

Stats
Goal: $100.00
Due Date: Mar 31
Gross Amount: $0.00
Net Balance: $0.00
Left to go: $100.00
Make donations with PayPal!

Latest GitHub Commits