PHP script within a page?

Creating and modifying plugins.
Post Reply
Eni
Regular
Posts: 62
Joined: Thu Jan 27, 2005 10:47 pm
Location: Münster, Germany

PHP script within a page?

Post by Eni »

Hi,

this is not really a plugin question but I don't know where to go with it... :?

I would like to have a external php show up in place of a static page or entry, is this possible? What I want to do is using phpHoo3 (yes yes, it's ancient but I like the layout a lot) for link management and then navigate to it via a main menu button "Links".

Can I have such a script embedded in Serendipity? If not, I will need to adapt my layout around the link database. But if it's possible, I'd prefer to stay within the blog urls.

Alternatively, I was thinking of having the linklist plugin (serendipity_plugin_linklist) show up on a page instead of the sidebar, but I suppose that isn't any easier to archive. And the phpHoo3 layout is nicer for a bigger link database, I guess.

Thank you for taking your time~ :)

~eni
Sorry, I'm Late. But I Got Lost On The Road Of Life.
Timbalu
Regular
Posts: 4598
Joined: Sun May 02, 2004 3:04 pm

Re: PHP script within a page?

Post by Timbalu »

Well it depends what you are actually up for, ... but you could try to use the WrapURL Event Plugin, which is able to wrap another page in an IFRAME to be displayed in the body.
Regards,
Ian

Serendipity Styx Edition and additional_plugins @ https://ophian.github.io/ @ https://github.com/ophian
Eni
Regular
Posts: 62
Joined: Thu Jan 27, 2005 10:47 pm
Location: Münster, Germany

Re: PHP script within a page?

Post by Eni »

Hi,

thanks for your answer.

Iframes are something I would only use as last option. I don't really like that solution when there's a direct possibility.

Eniways, I had a long break using Serendipity and apparently need to look more carefully into the documentation before I ask things here. Looks like I got the solution right here and the External PHP Application plugin does look good too. I will play around with these options before screaming further for help, thank you :)

~eni
Sorry, I'm Late. But I Got Lost On The Road Of Life.
Timbalu
Regular
Posts: 4598
Joined: Sun May 02, 2004 3:04 pm

Re: PHP script within a page?

Post by Timbalu »

Yes sure, I always forget about the "External PHP" plugin!

Another way is to set down security, but I am not sure we will keep that in future.
That is why I didn't mention it.

There is another option via the templates/config.inc.php file. If you go that way, you may include a (directory own) php file in there, keep it as a content var or array, modify things around and then assign it to smarty. Keeping in mind to change your index, entries or whatever .tpl file to be in charge of your mod, you are able to stay compatible without any plugin use. :wink:
Regards,
Ian

Serendipity Styx Edition and additional_plugins @ https://ophian.github.io/ @ https://github.com/ophian
Eni
Regular
Posts: 62
Joined: Thu Jan 27, 2005 10:47 pm
Location: Münster, Germany

Re: PHP script within a page?

Post by Eni »

Hi,

that sounds a bit too complicated for my skills. I managed to set up a little homepage with php arrays but that was very simple and had no foreign code to edit.

But with so much choice, what is the best or cleanest option to include an external php application? :?

~eni
Sorry, I'm Late. But I Got Lost On The Road Of Life.
Timbalu
Regular
Posts: 4598
Joined: Sun May 02, 2004 3:04 pm

Re: PHP script within a page?

Post by Timbalu »

Hmmm, I can't really say, as it depends on what you really want to do, or the application is doing.

Simple example
If you have an external php script (enifoo.php), which returns some ready to use preformated content, by return $content (for example), I'd say:

Create a config.inc.php file in your template, if you not already have.

There you set

Code: Select all

include 'enifoo.php';
if(isset($content) && !empty($content)) {
    $serendipity['smarty']->assign('conteni', $content);
}
Then create a new staticpage named sp_conteni, with the url named pages/eni.html, with a header or some text to wrap or describe the output of your php file.

Now you can use {$conteni} in your templates, to be set under the condition:

Code: Select all

{if $staticpage_pagetitle == 'sp_conteni'}... {$conteni} ... {/if}
http://www.enisweb.de/serendipity/pages/eni.html will now show the wrapper staticpage with the files output..., hopefully. :wink:
Regards,
Ian

Serendipity Styx Edition and additional_plugins @ https://ophian.github.io/ @ https://github.com/ophian
Eni
Regular
Posts: 62
Joined: Thu Jan 27, 2005 10:47 pm
Location: Münster, Germany

Re: PHP script within a page?

Post by Eni »

Hm, I'm not sure if I understand it correct. I have a logic disorder, so programming really isn't my cup of tea, although I grasp some basics. It takes me a very long time to understand the steps. I tested the iFrame wrap now and it works fine but I don't want this as permanent solution. So tried the External PHP plugin next and run into a problem, it seems.

I found a nice link management now that I installed. Now I added the External PHP plugin and set the links up correctly in the ACP. However, Yald uses Smarty too and this seems to cause a problem, as it gives me this error when I try to open the link within serendipity:

Code: Select all

Fatal error: Cannot redeclare class Smarty in /var/www/socialcuriosity/yald/inc/smarty/Smarty.class.php on line 65
The file in question: http://pastebin.com/qWtDD9ue

Is it not possible to use this plugin on a application that uses Smarty as well, or include such an application in serendipity generally? Or is there something else I need to do aside from setting the plugin in the ACP? :?

~eni
Sorry, I'm Late. But I Got Lost On The Road Of Life.
Timbalu
Regular
Posts: 4598
Joined: Sun May 02, 2004 3:04 pm

Re: PHP script within a page?

Post by Timbalu »

Eni wrote:Is it not possible to use this plugin on a application that uses Smarty as well, or include such an application in serendipity generally? Or is there something else I need to do aside from setting the plugin in the ACP?
As the error already says, you cannot use two Smarty systems in the same enviroment. It should work through the wrap plugin though.
If you are sure the Smarty engine (btw a very old one) is an includement only bei Yald, and not changed, you could try to make Yald use the Smarty engine of Serendipity only, which would avoid that problem. Please explain ACP?

You could try to disable the require part in Yalds suggest.php and directory.php with a # and see if that already works....

Code: Select all

#require('inc/smarty/Smarty.class.php');
If there is more to do, this would efford at least some programming skills...
Regards,
Ian

Serendipity Styx Edition and additional_plugins @ https://ophian.github.io/ @ https://github.com/ophian
Eni
Regular
Posts: 62
Joined: Thu Jan 27, 2005 10:47 pm
Location: Münster, Germany

Re: PHP script within a page?

Post by Eni »

Timbalu wrote:If you are sure the Smarty engine (btw a very old one) is an includement only bei Yald, and not changed, you could try to make Yald use the Smarty engine of Serendipity only, which would avoid that problem.
Yald is very small, only containing of a handful of files. So I suppose I could try that. Hmm. I don't really know much about smarty but I will look into the files later.
Timbalu wrote:Please explain ACP?
Admin Control Panel. I was wondering whether the External PHP plugin needed any other configuration besides the plugin settings in Serendipity's admin area to have an external PHP application work.
Timbalu wrote:You could try to disable the require part in Yalds suggest.php and directory.php with a # and see if that already works....

Code: Select all

#require('inc/smarty/Smarty.class.php');
If there is more to do, this would efford at least some programming skills...
Hm, yes. I think I will leave it in the wrapper for now and finish the other blog modifications on my todo list first. Else it will never go live in time :lol:

Thank you for your help. I'll get back to this in a couple of days, depending on my schedule.

~eni
Sorry, I'm Late. But I Got Lost On The Road Of Life.
Post Reply