Smarty Forum Index Smarty
WARNING: All discussion is moving to https://reddit.com/r/smarty, please go there! This forum will be closing soon.

Load a image from its ID from another page

 
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> General
View previous topic :: View next topic  
Author Message
ofkings
Smarty n00b


Joined: 26 Feb 2018
Posts: 3

PostPosted: Mon Feb 26, 2018 3:13 am    Post subject: Load a image from its ID from another page Reply with quote

i want to load a image using its ID that is in other pages, not the path,

something like this:
page that ill load the image
Code:
<img src="banner001" alt="" width="600" height="250" />


image code in the other page
Code:
<img id="banner001" img" src="images/news/nGC158s.jpg"  />


this is possible?
Back to top
View user's profile Send private message
AnrDaemon
Administrator


Joined: 03 Dec 2012
Posts: 1785

PostPosted: Mon Feb 26, 2018 12:04 pm    Post subject: Reply with quote

Pages don't know about eachother.
Back to top
View user's profile Send private message
bsmither
Smarty Elite


Joined: 20 Dec 2011
Posts: 322
Location: West Coast

PostPosted: Tue Feb 27, 2018 1:59 am    Post subject: Reply with quote

Having access to the "other page's" template means you should also have access to the functions that calculated the values which were assigned to the Smarty template variables (which are to be used in the other template).

If you do not have access to the same function that determined the value of the other page's image source value, but you know that this value has been assigned to a Smarty template variable, then you can ask Smarty to get it:
Code:
$imgOtherTemplate = $Smarty->getTemplateVar("ID_BANNER001");
$Smarty->assign("BANNER001", $imgOtherTemplate);
Back to top
View user's profile Send private message
ofkings
Smarty n00b


Joined: 26 Feb 2018
Posts: 3

PostPosted: Tue Feb 27, 2018 4:03 am    Post subject: Reply with quote

Code:
foreach item=curnews from=$news}
            
                  <div class="newsCont">
                            <div class="date">{$curnews.date|date_format:"%m/%d"} <font class="bold_date">{$curnews.date|date_format:"%Y"}</font></div>
                            <a href="{$base_url}index.php?act=newsview&id={$curnews.id}" onfocus="this.blur()" class="header">{$curnews.headline}</a>
                            <div class="tab">
                     
                     {if $curnews.category eq News}<img src="images/news/tab_notice.png" /><font size="5" color="grey"></font color>{/if}
                     {if $curnews.category eq Events}<img src="images/news/tab_event.png" /><font size="5" color="grey"></font color>{/if}
                     {if $curnews.category eq Updates}<img src="images/news/tab_update.png" /><font size="5" color="grey"></font color>{/if}
                     {if $curnews.category eq Patches}<img src="images/news/tab_patches.png" /><font size="5" color="grey"></font color>{/if}
                            </div>
                            <a href="{$base_url}index.php?act=newsview&id={$curnews.id}" class="summary"><p>
                     
                     <img src="id from image from other page" alt="" width="600" height="250" />
                     
                  
                     </p></a>
                        </div>
                        <div class="line_news">
                        </div>
            {/foreach}


the user admin register news in the news manage page, this code above display the news in the index page, as you can see in this printscreen i can get title, categorie and date, just cant get the banner, each news have a diferent banner, so i looking for a way to load it in the index page using ID or soemthing like that

https://prnt.sc/ik8l4c

it should look like this one:
https://prnt.sc/ik8vib
Back to top
View user's profile Send private message
bsmither
Smarty Elite


Joined: 20 Dec 2011
Posts: 322
Location: West Coast

PostPosted: Tue Feb 27, 2018 5:29 am    Post subject: Reply with quote

You also have $curnews.id, and that means it will be easy to determine the image that each news_id database record has associated with it.

So, when building the array that gets assigned to the Smarty variable $news, also include in each element array the image associated with it.

Then, you have this available: $curnews.image
Back to top
View user's profile Send private message
ofkings
Smarty n00b


Joined: 26 Feb 2018
Posts: 3

PostPosted: Tue Feb 27, 2018 3:35 pm    Post subject: Reply with quote

sorry for newbie questio, how i do that?
Back to top
View user's profile Send private message
bsmither
Smarty Elite


Joined: 20 Dec 2011
Posts: 322
Location: West Coast

PostPosted: Tue Feb 27, 2018 5:45 pm    Post subject: Reply with quote

There are dozens of ways to gather data from a database, get it ready for public consumption, then lastly assign it to a Smarty variable.

To be any more specific on what to look for and what to change in your PHP script would be futile.

Do you have a way to contact the script author?
Back to top
View user's profile Send private message
Display posts from previous:   
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> General All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group
Protected by Anti-Spam ACP