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

HTML woes ...!

 
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
DeanPickersgill
Smarty n00b


Joined: 07 Feb 2016
Posts: 4

PostPosted: Sun Feb 07, 2016 11:56 am    Post subject: HTML woes ...! Reply with quote

Hi everyone, I'm new here and would appreciate some help with the following problem ...

1) In my Smarty template I have a {foreach} which puts a series of numbers into a variable {$myvariable}.

2} I expect to be able to see the contents of that variable in 'resultpage.html'

3} I put 'The resulting number is {$myvariable}' into the HTML page.

Now, if I {include} resultpage.html it shows 'The resulting number is 200'. However if I load the page via an <a href="resultpage.html"> it shows 'The resulting number is {$myvariable}'

As I say, {include} gives me the result I expect - but I don't want to "include" the page, I want to click on a link and have the contents of the variable passed to the called page.

{assign} or {capture} don't seem to make that variable available ...

Can anyone help please?

Thanks in advance for the use of your brainpower Smile

Rgds Dean
Back to top
View user's profile Send private message
AnrDaemon
Administrator


Joined: 03 Dec 2012
Posts: 1785

PostPosted: Sun Feb 07, 2016 5:02 pm    Post subject: Reply with quote

1. You're doing it wrong.
2. You're doing it wrong.
3. This is not a Smarty question.
If you are not parsing HTML files for PHP code on server, of course nothing will happen.
Go back to the books. Read what is PHP, read what is Smarty, and read how HTTP works.
Back to top
View user's profile Send private message
DeanPickersgill
Smarty n00b


Joined: 07 Feb 2016
Posts: 4

PostPosted: Sun Feb 07, 2016 6:33 pm    Post subject: Thanks for the advice Reply with quote

Hmm, in the amount of time it took you to write that you could have offered some insight or useful advice. Never mind, I'll take my cap off to you and concede your greater wisdom in any case.

All the best
Dean
Back to top
View user's profile Send private message
AnrDaemon
Administrator


Joined: 03 Dec 2012
Posts: 1785

PostPosted: Mon Feb 08, 2016 12:35 am    Post subject: Reply with quote

I already told you, that what you are doing is wrong, not possible, and not explained in any example you might find in the documentation.
If you want me to retype entire chapters from the book, you have to pay for my time.
Back to top
View user's profile Send private message
DeanPickersgill
Smarty n00b


Joined: 07 Feb 2016
Posts: 4

PostPosted: Mon Feb 08, 2016 3:56 pm    Post subject: Engage brain before opening mouth. Reply with quote

... Try using {capture} to get MyVariable, then reference it in the HTML page with a {html_options options=$myVariable} without the 'selected' tag.

I expect that won't work, is wrong, and not possible.

Have a lovely day, Maestro.

Rgds Dean Rolling Eyes
Back to top
View user's profile Send private message
AnrDaemon
Administrator


Joined: 03 Dec 2012
Posts: 1785

PostPosted: Mon Feb 08, 2016 9:42 pm    Post subject: Reply with quote

Yes, it is wrong, not possible and will not work, when you refer to "resultpage.html" directly, unless it is actually your PHP script. Stop pulling my words out of context.
Back to top
View user's profile Send private message
sarahfoxnz
Smarty Regular


Joined: 11 Apr 2010
Posts: 76

PostPosted: Mon Feb 15, 2016 10:24 am    Post subject: Re: HTML woes ...! Reply with quote

DeanPickersgill wrote:

1) In my Smarty template I have a {foreach} which puts a series of numbers into a variable {$myvariable}.


Nope - smarty template is only to display the results of any processing..

the creation of an array should be done in the PHP script, and only the end / resulting array should be sent to the smarty template to be displayed.



DeanPickersgill wrote:


3} I put 'The resulting number is {$myvariable}' into the HTML page.

Now, if I {include} resultpage.html it shows 'The resulting number is 200'. However if I load the page via an <a href="resultpage.html"> it shows 'The resulting number is {$myvariable}'


As I say, {include} gives me the result I expect - but I don't want to "include" the page, I want to click on a link and have the contents of the variable passed to the called page.



You need to process / organise your $myvariable before hand - in a PHP script... & then the php script sends it to (calls) the template..
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