Code: Select all
[html]<a href="javascript:history.back(1)">Back</a>[/html]
Code: Select all
[html]<a href="javascript:history.back(1)">Back</a>[/html]
Haha I am well aware on how to create a back link in Javascript. If you read my post again, that is not exactly what I am trying to do here. It is appreciated, though.Lubomír Ludvík wrote: ↑Tue Feb 16, 2021 10:47 am Tongara: Move to the previous pageCode: Select all
[html]<a href="javascript:history.back(1)">Back</a>[/html]
Tongara wrote: ↑Mon Feb 15, 2021 9:03 am With how my website is set up, I wanted the option of adding a custom "Back" link to Static pages much like you see on the main news post pages and index page of flatpress. The idea would be that the static.tpl would contain a line of code for the back button, and it would somehow grab it's code from elsewhere on a static page using a PHP echo so that I could define the target URL on the fly.
So, on the static template the "a href" would work something like this:Then of course comes the plugin code, which can be seen in the following file:Code: Select all
<a href="<?php echo $link;?>">Back</a>
https://mega.nz/file/8lgXDSSL#dKqbPuJYp ... v8vjcLJgYY
Then based on the code above, I define the actual link on a Static page in the following way:Sadly, the URL never gets defined, and as such the URL ends up as "mysite.com/<?php%20echo%20$link;?>" instead of "mysite.com/pagename".Code: Select all
[pagelinks]pagename[/pagelinks]
I've made sure the plugin is enabled, and I can see in the site's header that the plugin is loaded on the page. I'm sure I'm just missing something really small and I'm going to feel like an idiot when it's pointed out what I'm doing wrong, but the forums are here to help support us, so I'm looking forward to feel foolish! haha
Maybe there is a better way than using PHP for this task? I'm open to ideas!
You need to tell your plugin to assign Smarty variables.
Code: Select all
function yourFunction() {
global $smarty;
$smarty->assign('yourvariable', 'some value');
Code: Select all
<a href="{$yourvariable}">Back</a>
This might look like an easy time saver, but be aware that this opens a complete new dimension of risk.Lubomír Ludvík wrote: ↑Mon Feb 15, 2021 2:09 pm plugin inlinephp
http://flatpress.cz/flatpress/fp-plugin ... inephp.zip
Code: Select all
[exec]echo(rand(10,100)); echo PHP_VERSION;[/exec]
Found a few files there These two can be deleted?
Would I still be able to set what that variable is on a per static page basis (as my code awas attempting to allow me), or would it just be the same variable every time? Because the former is the desired behaviour.Arvid wrote: ↑Sat Feb 20, 2021 12:21 pm You need to tell your plugin to assign Smarty variables.These can then be used in the templates:Code: Select all
function yourFunction() { global $smarty; $smarty->assign('yourvariable', 'some value');
Code: Select all
<a href="{$yourvariable}">Back</a>
Unfortunately, I am too short of time atm to build working example codeTongara wrote: ↑Sat Feb 20, 2021 6:29 pm Would I still be able to set what that variable is on a per static page basis (as my code awas attempting to allow me), or would it just be the same variable every time? Because the former is the desired behaviour.
I'm also a bit overwhelmed about how to add such to my existing code, so any advice with the code I've posted would be super.
Done
Users browsing this forum: Ahrefs [Bot] and 102 guests