View previous topic :: View next topic |
Author |
Message |
DeanPickersgill Smarty n00b
Joined: 07 Feb 2016 Posts: 4
|
Posted: Sun Feb 07, 2016 11:56 am Post subject: HTML woes ...! |
|
|
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
Rgds Dean |
|
Back to top |
|
AnrDaemon Administrator
Joined: 03 Dec 2012 Posts: 1785
|
Posted: Sun Feb 07, 2016 5:02 pm Post subject: |
|
|
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 |
|
DeanPickersgill Smarty n00b
Joined: 07 Feb 2016 Posts: 4
|
Posted: Sun Feb 07, 2016 6:33 pm Post subject: Thanks for the advice |
|
|
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 |
|
AnrDaemon Administrator
Joined: 03 Dec 2012 Posts: 1785
|
Posted: Mon Feb 08, 2016 12:35 am Post subject: |
|
|
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 |
|
DeanPickersgill Smarty n00b
Joined: 07 Feb 2016 Posts: 4
|
Posted: Mon Feb 08, 2016 3:56 pm Post subject: Engage brain before opening mouth. |
|
|
... 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 |
|
Back to top |
|
AnrDaemon Administrator
Joined: 03 Dec 2012 Posts: 1785
|
Posted: Mon Feb 08, 2016 9:42 pm Post subject: |
|
|
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 |
|
sarahfoxnz Smarty Regular
Joined: 11 Apr 2010 Posts: 76
|
Posted: Mon Feb 15, 2016 10:24 am Post subject: Re: HTML woes ...! |
|
|
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 |
|
|