Admin Required Link

This is the right place to report general bugs, make suggestions or ask for help.
User avatar
WineMan
Posts: 75
Joined: Tue Sep 01, 2020 5:03 pm

Admin Required Link

Post by WineMan » Tue Aug 02, 2022 4:22 pm

Is it possible to set up a static page or any other linked page that only the admin can access? I looked for a plugin that might do this, but if it exists I wasn't able to find it. Thanks in advance.

George
Posts: 31
Joined: Tue May 18, 2021 10:54 am
Location: Uk
Contact:

Re: Admin Required Link

Post by George » Tue Aug 02, 2022 7:05 pm

just create a new static page but do not add it to the menu
Proudly using flatpress https://www.mypoppy.uk/blog

User avatar
WineMan
Posts: 75
Joined: Tue Sep 01, 2020 5:03 pm

Re: Admin Required Link

Post by WineMan » Tue Aug 02, 2022 8:51 pm

Thanks George, I tried that but can't get php code to work in a static page. Is it possible?

George
Posts: 31
Joined: Tue May 18, 2021 10:54 am
Location: Uk
Contact:

Re: Admin Required Link

Post by George » Wed Aug 03, 2022 5:14 am

The {php} tag is disabled by default. Enable with $smarty->allow_php_tag=true
Proudly using flatpress https://www.mypoppy.uk/blog

User avatar
WineMan
Posts: 75
Joined: Tue Sep 01, 2020 5:03 pm

Re: Admin Required Link

Post by WineMan » Wed Aug 03, 2022 9:16 am

Where do I enable that? I'm still trying to figure out this blog application. And thanks for the response.

V...ger
Posts: 4
Joined: Fri Jul 29, 2022 3:38 pm

Re: Admin Required Link

Post by V...ger » Wed Aug 03, 2022 3:44 pm

Hey George; Wineman and I are partners in crime with the blog. I searched through almost all of the Smarty files and can't seem to find where to set php tags to true. I think we're gonna need some pointers here. :o

User avatar
fraenkiman
Posts: 32
Joined: Thu Feb 03, 2022 7:25 pm
Location: Berlin, Germany
Contact:

Re: Admin Required Link

Post by fraenkiman » Wed Aug 03, 2022 7:52 pm

Hello, everyone,

apparently you have to put this in the new static admin page.

I found this about it.
Arvid may have a code snippet; PHP+Smarty is not my forte.

Best regards
My Flatpress-Blog [German]: https://frank-web.dedyn.io

User avatar
Arvid
FlatPress Coder
Posts: 414
Joined: Sat Jan 26, 2019 7:40 pm
Contact:

Re: Admin Required Link

Post by Arvid » Thu Aug 04, 2022 6:01 pm

George wrote: Tue Aug 02, 2022 7:05 pmjust create a new static page but do not add it to the menu
It may not be "visible" on your site, but always remains publicly accessible through the direct link. Not a good idea if you want to protect information from the public - which is what I think WineMan tries to achieve. That said, ...
WineMan wrote: Tue Aug 02, 2022 4:22 pmIs it possible to set up a static page or any other linked page that only the admin can access?
...what's the purpose of doing so? What do you try to achieve?

WineMan wrote: Tue Aug 02, 2022 8:51 pmI tried that but can't get php code to work in a static page.
Just tested the Inline PHP plugin, works like a charm. Install and enable it, and then add your PHP code encapsulated in [exec] tags to your static page:

Code: Select all

Current time is [exec]echo  date('Y-m-d H:i:s T');[/exec]
But, as mentioned here, I strongly recommend rather building a plugin around the PHP code (which I still have no idea what its purpose is) than using the Inline PHP plugin in public FlatPress instances.

All the best,
Arvid
Helpful FlatPress links: Project blog 📝 - FlatPress wiki 📖 - FlatPress@Twitter 🐦 - FlatPress@Mastodon 🐘
Stay up to date with our feeds: Forum RSS feed 📜 - Project blog RSS feed 📜
Feel free to say Thank you: Donate ❤️

🇩🇪 Für meinen Arbeitgeber in Bochum habe ich zwei Stellen zu besetzen: Junior-Systemadministrator, Ausbildung zum Fachinformatiker Systemintegration 🇩🇪

User avatar
WineMan
Posts: 75
Joined: Tue Sep 01, 2020 5:03 pm

Re: Admin Required Link

Post by WineMan » Wed Aug 10, 2022 3:44 am

Arvid,

I have been playing around with the inlinePHP plugin and can't seem to make it work. I am specifically trying it on this code:

Code: Select all

if(!file_exists("data.txt"))
    {
        echo "The file cannot be found!";
        exit;
    }
    
    $fp = fopen("data.txt", "r");
    
    if(!$fp)
    {
        echo "File cannot be opened";
        exit;
    }
    echo "<table border = 2>";
    
    while(!feof($fp))
        {
            $info = fgets($fp);
			echo "<tr>";
			
            echo "<td>$info</td>\n";
			
			echo "<br />";
        }
        echo "</tr>\n";
        echo "</table>";
    fclose($fp)
I left out some of the html code that goes before the php code. Am I misunderstanding how it is supposed to work?

George
Posts: 31
Joined: Tue May 18, 2021 10:54 am
Location: Uk
Contact:

Re: Admin Required Link

Post by George » Wed Aug 10, 2022 8:19 am

as Arvid said in his previous post your PHP code needs to be encapsulated in [exec]php code [/exec]
Proudly using flatpress https://www.mypoppy.uk/blog

Post Reply

Who is online

Users browsing this forum: No registered users and 2 guests