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

  • alain01

  • Just can't stay away

  • Posts: 530

  • 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



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

  • alain01

  • Just can't stay away

  • Posts: 530

  • 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.



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

  • Mamba

  • Moderator

  • Posts: 11374

  • Since: 2004/4/23


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



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

  • alain01

  • Just can't stay away

  • Posts: 530

  • 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.



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

  • zyspec

  • Module Developer

  • Posts: 1095

  • Since: 2004/9/21


@alain01,

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.



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

  • Mamba

  • Moderator

  • Posts: 11374

  • Since: 2004/4/23


This is how you could do it (this is for the xbootstrap theme and the Publisher module):

1) create directory "images" in "publisher" folder in your theme, e.g.
/themes/xbootstrap/modules/publisher/images/

2) copy the image of your choice to this folder, and name it e.g. "search.png"

Repeat it for all modules that you want to modify.
Note: the name of the file should be the same for all modules!

3) copy the file "system_search.tpl"
from /modules/system/templates/
to /themes/xbootstrap/modules/system/

4) modify the file "system_search.tpl" around line 17:

<{foreach item=data from=$search.module_data}>
            <
img src="<{$data.image_link}>" title="<{$data.image_title}>" alt="<{$data.image_title}>"/> <a href="<{$data.link}>"><{$data.link_title}></a>


to this:

<{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"}>
            <{if 
file_exists($image)}>
                   <
img src="<{$image}>"
                   
<{else}>
                   <
img src="<{$data.image_link}>"
            
<{/if}>
                 
title="<{$data.image_title}>" alt="<{$data.image_title}>"/> <a href="<{$data.link}>"><{$data.link_title}></a>
<{*----------- new 
code ends -------------*}>


Now if you go tohttp://myxoopssite/search.php and do the search, Publisher will show you the new icons.
Support XOOPS => DONATE
Use 2.5.10 | Docs | Modules | Bugs



637
alain01
Re: Overload the images on the search.php page
  • 2021/10/20 6:16

  • alain01

  • Just can't stay away

  • Posts: 530

  • Since: 2003/6/20


yes, absolute path.
Thank you for the links .

<{assign var="chaine_surcharge" value=$xoops_imageurl|cat:"modules/"|cat:$result.image|replace:"$xoops_url/modules/":''}>
                        
chaine_surcharge : <{$chaine_surcharge}> <br />

                        <{if 
file_exists($chaine_surcharge)}>
                            <
div class="d-inline"><img src="<{$chaine_surcharge}>" alt="<{$module.name}>"> <a href="<{$result.link}>"><{$result.title}></a></div>
                            <
div class="d-none d-md-inline "><span class="fas fa-calendar fa-sm ml-2"></span> <{$result.time}></div>
                            <
br />
                        <{else}>
                            <
img src="<{$result.image}>" alt="<{$module.name}>"> <a href="<{$result.link}>"><{$result.title}></a> (<{$result.time}>)<br />
                        <{/if}>


Result:
chaine_surcharge :http://xoops-tests2.local/themes/mx-theme/modules/xmnews/assets/images/xmnews_search.png

and the test is always false so the overloaded does not work.

Quote:
In smarty, you cannot use file_exists() on a URL, but you can use it on a local file

I think, the best way is to check in your controller.

I tried

<{$file_headers = @get_headers($chaine_surcharge)}>
                        
file_headers = <{$file_headers}> <br />


but the result is :
Quote:
file_headers =



638
Mamba
Re: Overload the images on the search.php page
  • 2021/10/19 23:33

  • Mamba

  • Moderator

  • Posts: 11374

  • Since: 2004/4/23


Are you using the absolute path? At least that's what they're talking about it here

See also here
Support XOOPS => DONATE
Use 2.5.10 | Docs | Modules | Bugs



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

  • alain01

  • Just can't stay away

  • Posts: 530

  • Since: 2003/6/20


Thank you for the syntax, zyspec,
but it does not work.

<{if file_exists($chaine_surcharge)}>
                            <
div class="d-inline"><img src="<{$chaine_surcharge}>" alt="<{$module.name}>"> <a href="<{$result.link}>"><{$result.title}></a></div>
                            <
div class="d-none d-md-inline "><span class="fas fa-calendar fa-sm ml-2"></span> <{$result.time}></div>
                            <
br />
                        <{else}>
                            <
img src="<{$result.image}>" alt="<{$module.name}>"> <a href="<{$result.link}>"><{$result.title}></a> (<{$result.time}>)<br />
                        <{/if}>

The condition is always false... but the file exists

If I delete the test, the image is overloaded.



640
zyspec
Re: Overload the images on the search.php page
  • 2021/10/19 20:36

  • zyspec

  • Module Developer

  • Posts: 1095

  • Since: 2004/9/21


@alain01

You should be able to just use something like this:
<{if file_exists($chaine_surcharge)}>
Found my file<br>
<{else}>
Unknown file<br>
<{/if}>




TopTop
« 1 ... 61 62 63 (64) 65 66 67 ... 29424 »



Login

Who's Online

123 user(s) are online (83 user(s) are browsing Support Forums)


Members: 0


Guests: 123


more...

Donat-O-Meter

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

Latest GitHub Commits