display_dat, start page identifier and author

Discussion corner for Developers of Serendipity.
Post Reply
loli
Regular
Posts: 8
Joined: Tue Jan 16, 2007 1:22 pm

display_dat, start page identifier and author

Post by loli »

Hello,

i (again) could need some help.

I have 3 questions right now:

First:
I want to identify the index page of the blog. I currently use

Code: Select all

strpos($serendipity['GET']['subpage'], "?/index.php")
but I'm quite sure that's not a clean way :)
Is there a better way?

Second:
I want to put some code in front of the displayed entries. But I can only get it behind the entries with the 'display_dat' from the "frontend_display:html:per_entry"-hook.
I'm currently trying to manage some work around with a combination of "entries_header", "entry_display" and "frontend_display:html:per_entry":

"frontend_display:html:per_entry" should display every itemfor the second-to-last entry, the other two only for the first. The problem is, that I'm depended on the 'authorId', which I can get in "entry_display" but not in "entries_header". On the other hand isn't it possible to print any HTML with "entry_display".

Creating the HTML with "entry_display" and displaying it with "entries_header" isn't an option, cause "entries_header" is called first.

...
I hope somebody even undestands what I wanna say :P

(Creating a new Hook is out of question, because I want to create an independant plugin).

Third:
I wrote another Plugin, which allowes the administrator to publish a post under the name of another user (actually, it's their post after saving).

I'm using the "backend_entry_presave"-Hook to change the 'authorId' in the Entry-Data before saving.

This works fine with a new entry, because the 'authorId' is set with

Code: Select all

if(!isset($entry_data['authorId'])) $entry_data['authorId'] = $current_user['id'];
(no actual code, just the same meaning).

But when an existing entry is beeing edited, 'authorId' is set without asking if it is already defined.

I currently just change the method code, but therefore lost all usability as a plugin.

Any idea (without editing serendipity code)?


Thanks again,
loli
loli
Regular
Posts: 8
Joined: Tue Jan 16, 2007 1:22 pm

Post by loli »

The first issue got even more pressing now. I embed the Blog into a Typo3 System and now the $serendipity['GET']['subpage'] isn't set anymore!

Please, anybody an idea?
garvinhicking
Core Developer
Posts: 30022
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Re: display_dat, start page identifier and author

Post by garvinhicking »

Hi!

About the first solution: Serendipity sets a variable $GLOBALS['uri_addData']['startpage'] which is set to 'true' in case that s9y displays its frontpage. However why $serendipity gets unset in Typo3 I can't really tell...I have no experience with Typo3 and embedding. :(

Second: You can edit your entries.tpl template and there either invent a new plugin API hook that your plugin uses, or you could shuffle the position of the display_dat output. But you said that inventing a new hook is out of the question, so you only have very limited options that remain.

You might need to make your plugin modif $eventData['body'] directly, using the entries_header hook. There's no other plugin hook yet invented that deals with pre-entry output, I'm sorry.

About issue 3, have you looked into the entryproperties plugin? This one allows to change the owner of an entry with saving, so you should be able to use the same code?

Best regards,
Garvin
# Garvin Hicking (s9y Developer)
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/
loli
Regular
Posts: 8
Joined: Tue Jan 16, 2007 1:22 pm

Post by loli »

Issue 1:
Thanks, I will use this Var ... seems far more secure to me than my aproach.
Typo 3 calls Serendipity from INSIDE a function, so $serendipity isn't set globaly .. just had to set an "global $serendipity' in the index.php.

Issue 2:
I just replaced the hook ... after starting to embed the whole thing into Typo 3, i had to give up my aproach on potability completely so no harm done with one line more changed.
But perhaps a new Hook for newer versions?

Issue 3:
I couldn't track down the "entryproperties" (or whatever, i even read the descriptions) Plugin via Spartacus. Isn't it included there? (Event Plugins)

And if it only allowes this on creating a new Post.. there it all works just fine .. just when editing an trying to change the author ist failes.

Thx for the help,
loli

PS: Irgendwie beschleicht mich das Gefühl, dass ich auch deutsch reden könnte ...
[/b]
garvinhicking
Core Developer
Posts: 30022
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Post by garvinhicking »

Hi!
But perhaps a new Hook for newer versions?
Basically that would be nice, but the problem is performance. The more hooks we add in places that are executed often (like header, footer, body hooks) the more impact we have. So I actually prefer to use CSS to place some things of the footer at the top of an entry instead, if possible...?
I couldn't track down the "entryproperties" (or whatever, i even read the descriptions) Plugin via Spartacus. Isn't it included there? (Event Plugins)
This plugin is included by default to serendipity. It's real name is "Extended Properties for Entries" (serendipity_event_entryproperties).
PS: Irgendwie beschleicht mich das Gefühl, dass ich auch deutsch reden könnte ...
Dazu sag ich nix ;)

Best regards,
Garvin
# Garvin Hicking (s9y Developer)
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/
loli
Regular
Posts: 8
Joined: Tue Jan 16, 2007 1:22 pm

Post by loli »

Oh... found the plugin (must have been blind) ... but .. oh, yes, yeah (nice to be right, even if it's only this time and on behalf of somebody else) -> Bug: If you publish a new entry or edit one, the "Author" - Funktion of the "serendipity_event_entryproperties" doesn't seem to work! (Perhaps it's because of all the changes I did in the source code, but just now I can't imagine what could have triggered this).

... Bug gefunden, Bug gefunden *hüpf*

Greetings,
loli
Post Reply