Page 1 of 2

PHP in a plugin

Posted: Mon Oct 15, 2007 10:27 pm
by kehbop
I want to put some PHP and HTML code in a plugin that will fetch the newest images from my coppermine album.

So basically, I want to make a custom plugin.

Will the html nugget work? How bout gutting a pre-existing plugin and replacing it with my own code?

Can someone tell me how to approach this?

Re: PHP in a plugin

Posted: Tue Oct 16, 2007 10:27 am
by garvinhicking
Hi!

The HTML nugget is not for PHP code. You'll need to create your own plugin!

However, there is already a "Media sidebar" plugin that can output plugins from a gallery installation. Checkout serendipity_plugin_imagesidebar (on spartacus), this already has a coppermine_sidebar.php file that you might want to modify.

Regards,
Garvin

simple PHP-include (for text-file) - Plugin a must?

Posted: Wed Oct 24, 2007 1:12 pm
by Nicola
Hi!

May I add a related question?!

In this Page: http://www.shopanbieter.de/news/index.php

I would like to 'extract' the code parts of the main menue (top) as well as of the newsletter-box (right) into separate text-files as both are elements of the whole site and should be maintained in a central file (e.g. mainmenue.inc)

So I need to make something like this:
<? include('include/common_navi.php');?>

Only of course, this doesn't work. So do I really need to create plugins for this simple task? Isn't there some smarty-something that does a simple include or so?

Thanks for your hints (I did not really understand the plugin-concept as described here: http://www.s9y.org/78.html#A4, I'm more in HTML and only very very basic PHP, like 'include' ;-((

Nicola

Posted: Wed Oct 24, 2007 1:48 pm
by carl_galloway
You could use the smarty include function which is identical to the php version, for example {include file="file name"} where 'file name' is the .inc, or .tpl file

Re: simple PHP-include (for text-file) - Plugin a must?

Posted: Wed Oct 24, 2007 1:48 pm
by garvinhicking
Hi!

Check the "include_php" command from smarty. First you need to disable smarty security in your template's config.inc.php file:

Code: Select all

<?php
$serendipity['smarty']->security = false;
?>
to be able to use that inside your .tpl files.

Regards,
Garvin

Re: simple PHP-include (for text-file) - Plugin a must?

Posted: Wed Oct 24, 2007 2:22 pm
by Nicola
Hi to both of you!
garvinhicking wrote:Hi!
Check the "include_php" command from smarty. First you need to disable smarty security in your template's config.inc.php file:
I read about that at the mentioned page. And dismissed this option
because I fear, that this means that ma project then be somehow
'insecure'... Is it?

Greetings
Nicola

Re: simple PHP-include (for text-file) - Plugin a must?

Posted: Wed Oct 24, 2007 4:34 pm
by garvinhicking
Hi!

Well, it's the only way. If you want to include a foreign piece of code (which your header/footer is), you can only do it that way, or not include it at all. :)

Regards,
Garvin

Re: simple PHP-include (for text-file) - Plugin a must?

Posted: Tue Oct 30, 2007 12:08 pm
by Nicola
Hi!
garvinhicking wrote: in your template's config.inc.php file:
Seems, I'm to dumb or to blind ;-( Where do I find this file? It's
NOT in _my_ Template-Folder (nor in one of the others like "default",
as I can see). Nor can I find it somewhere else. Not a
"config.inc.php", nor a
"config.inc.php.file" (as written on http://www.s9y.org/78.html#A4,
but that's a mistake, is it? Just wanted to be sure about the name...)

Should I create such a file? Inside my Template-Folder and/or
any template folders, I've have (I use an nother template-style
for one special cathegory)?

TIA
Nicola

Re: simple PHP-include (for text-file) - Plugin a must?

Posted: Tue Oct 30, 2007 12:29 pm
by garvinhicking
Hi!

This file might not exist for your template. You can create the file, if it's not there.

Regards,
Garvin

Re: simple PHP-include (for text-file) - Plugin a must?

Posted: Tue Oct 30, 2007 9:53 pm
by Nicola
[quote="garvinhicking"]This file might not exist for your template. You can create the file, if it's not there./quote]

Thanks - works very well!

Regards
Nicola

Re: simple PHP-include (for text-file) - Plugin a must?

Posted: Wed Oct 31, 2007 10:24 am
by Nicola
Nicola wrote: Thanks - works very well!
Just, that it breaks the RSS-Feed:

XML-Verarbeitungsfehler: XML-Deklaration nicht am Beginn von externer Entität
Adresse: http://www.shopanbieter.de/news/feeds/index.rss2
Zeile Nr. 1, Spalte 2: <?xml version="1.0" encoding="utf-8" ?>
-^
http://www.shopanbieter.de/news/feeds/index.rss2

How does the 'insecure-Mode' affect the RSS-Feeds? Can I have
my includes AND a proper RSS-Feed?

As we _need_ the RSS-Feeds, I will have to return to old
Version very soon, so if You want to have a look, please
hurry ;-(

Greetings
Nicola

Re: simple PHP-include (for text-file) - Plugin a must?

Posted: Wed Oct 31, 2007 10:41 am
by Nicola
Hi!

Ok, what it does is this:

RSS-File 'normal' (=secure mode):
-----------------------------------------------
<?xml version="1.0" encoding="utf-8" ?>

<rss version="2.0"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:admin="http://webns.net/mvcb/"
xmlns:dc="http://purl.org/dc/elements/1.1/"
-----------------------------------------------

RSS File with "insecure-mode":
-----------------------------------------------
<?xml version="1.0" encoding="utf-8" ?>

<rss version="2.0"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:admin="http://webns.net/mvcb/"
xmlns:dc="http://purl.org/dc/elements/1.1/"
-----------------------------------------------

You see: It's a space that causes the problems...
Any idea, where this space comes from?
And - more important, how we get rid of it?

Thanks
Nicola

Re: simple PHP-include (for text-file) - Plugin a must?

Posted: Wed Oct 31, 2007 10:53 am
by Nicola
Mist. You don't see the space ;-(

Believe me, it's here:

RSS File with "insecure-mode":
-----------------------------------------------
_<?xml version="1.0" encoding="utf-8" ?>

<rss version="2.0"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:admin="http://webns.net/mvcb/"
xmlns:dc="http://purl.org/dc/elements/1.1/"
-----------------------------------------------

Re: simple PHP-include (for text-file) - Plugin a must?

Posted: Wed Oct 31, 2007 12:41 pm
by garvinhicking
Hi!

Make sure you don't have any spaces in your config.inc.php file - it comes from there.

regards,
Garvin

Re: simple PHP-include (for text-file) - Plugin a must?

Posted: Wed Oct 31, 2007 1:05 pm
by Nicola
garvinhicking wrote:Make sure you don't have any spaces in your config.inc.php file - it comes from there.
true, there it was. *SIGH*

THANKS!
Nicola