static frontpage mixes with contactform-feedback

Creating and modifying plugins.
Post Reply
mad-manne
Regular
Posts: 42
Joined: Wed Jan 23, 2008 4:56 pm
Location: Marl, Germany
Contact:

static frontpage mixes with contactform-feedback

Post by mad-manne »

Hi there,
I am running both the 'static pages'-plugin and the 'contactform'-plugin. Additionally I have *one* of my static pages defined as the frontpage of s9y.

While the "normal" contactform displays fine, the feedback(error-messages or the final success-message) appears mixed with the static frontpage, with the contactform-feedback below the static frontpage's content.

I have done some seraching and found tipps to move the contactform-plugin above the static-page(in the list of the event-plugins), but then the static frontpage doesn't appear at all :shock:

You can test all this over at my demoblog ...
Any other hints?

Cheers,
Manfred.

BTW: As this is rather a bug-report instead of an "Creating and modifying plugins."-issue ... should this still be posted in this forum or in the bugs-forum ??
Try not. Do or do not. There is no try. (YODA)
garvinhicking
Core Developer
Posts: 30022
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Re: static frontpage mixes with contactform-feedback

Post by garvinhicking »

Hi!

Sadly this is "by design". Your order was already proper, but the staticpage will always show up because it's the "frontpage", and the contactform plugin itself also submits to the frontpage.

With the current implementation of the Event-based system where every plugin can take on permalinks and does not know of other plugins, I don't think there's a real solution to this issue. The two plugins would need to be edited to make them aware of each other, but then still other plugins that submit to the frontpage (like the poll plugin or the 'Add user plugin') would also always force the static frontpage to display.

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/
mad-manne
Regular
Posts: 42
Joined: Wed Jan 23, 2008 4:56 pm
Location: Marl, Germany
Contact:

Re: static frontpage mixes with contactform-feedback

Post by mad-manne »

garvinhicking wrote:... where every plugin can take on permalinks and does not know of other plugins, I don't think there's a real solution to this issue.
Hi Garvin,
sadly enough I am still a greenhorn, when it comes to all this URL-rewriting stuff, or the way s9y-eventhooks work ...
Anyway I'd be willing to try and put some efforts into solving this problem. Could you give me a hint, in which file I could try to make the staticpage-plugin aware of the feedback of the contactform or is it rather too complex, due to the way things work in s9y ??

Cheers,
Manfred.
Try not. Do or do not. There is no try. (YODA)
garvinhicking
Core Developer
Posts: 30022
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Re: static frontpage mixes with contactform-feedback

Post by garvinhicking »

Hi!

You need to inspect the two plugin's event hooks "genpage", "entry_display" and "entries_header" inside the event_hook() method. How to connect them, I don't really know,because I don't know a solution.:)

In the past, some people actually wanted the static frontpage to show up...so if you use a static frontpage, it's actually part of the design that the content shows up which is meant to be the "startup" page.

Actually, the startup page simply means "the absence of all s9y error or archive pages", and this in turn is actually the place where other plugins "listen" to as well.

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/
mad-manne
Regular
Posts: 42
Joined: Wed Jan 23, 2008 4:56 pm
Location: Marl, Germany
Contact:

Post by mad-manne »

Hi Garvin,
thinking back to another answer you gave me here, I had the idea of adding an if-switch into the staticpage-template, that will just set the display:none-property on a given event.

In the contactform-plugin there are 2 booleans defined to know, if the form has been sent or if there was an error:

Code: Select all

$serendipity['smarty']->assign('is_contactform_sent', true);

...

$serendipity['smarty']->assign(
  array(
     'is_contactform_error'     => true,
Anyway I failed to find a way to set some boolean variable that would be available in the scope of the staticpage templates.

I had a look at one variable($serendipity['view']) that seems to be pretty "global", but I also failed to understand how this works.

So to cut a long story short:
Is there an easy way to set a smarty-variable in the contactform-plugin, that will also be available in the static-page templates ??

Looking forward to your answer,
Manfred.

EDIT: After giving this some more thoughts, I fear that this is not possible, because the staticpage-template will be rendered before the contactform due to the order of the event-plugins ?? Anyway as we say in german "Die Hoffnung stirbt zuletzt" :mrgreen:
Try not. Do or do not. There is no try. (YODA)
garvinhicking
Core Developer
Posts: 30022
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Post by garvinhicking »

Hi!

The idea is not so bad. Maybe just do it the opposite way around:

1. Put some unique CSS/DIV class into your staticpage plugin_staticpage.tpl file so that you can adress it via CSS

2. Emit inline style inside your contactform tpl, like:

Code: Select all

<style type="text/css">
.staticpage_div {
display: none
}
</style>
Inline style blocks like this are somewhat ugly, but they do work despite that fact, pretty well. So the contactform will hide the staticpage block (even though it's emitted before!) using CSS...

HTH,
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/
mad-manne
Regular
Posts: 42
Joined: Wed Jan 23, 2008 4:56 pm
Location: Marl, Germany
Contact:

Post by mad-manne »

garvinhicking wrote:So the contactform will hide the staticpage block (even though it's emitted before!) using CSS...
Hi Garvin,
I can report that this works like a charm :P
And what's even better: There's no need to change the php-side, because I can put that inline-css unconditional. Whenever there's output of the contactform-plugin, I want the staticpage to be hidden!

Here's what I did:
OPEN plugins/serendipity_event_staticpage/plugin_staticpage.tpl
and wrap the whole template into:

Code: Select all

<div class="staticpage_hide">
... / ....
</div>
OPEN
  • /plugins/serendipity_event_contactform/plugin_contactform.tpl
  • /plugins/serendipity_event_contactform/plugin_dynamicform.tpl
And add this on top of both files:

Code: Select all

{literal}
<style type="text/css">
.staticpage_hide {display: none;}
</style> 
{/literal}

But finally just to make that clear for me ...
The idea is not so bad. Maybe just do it the opposite way around
So does that mean, that my attempts to assign "global" smarty-variables that can be "passed" from one plugin to another will really not work ?!

Thanks for your help,
Manfred.
Try not. Do or do not. There is no try. (YODA)
garvinhicking
Core Developer
Posts: 30022
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Post by garvinhicking »

Hi!

Glad that trick works :)
So does that mean, that my attempts to assign "global" smarty-variables that can be "passed" from one plugin to another will really not work ?!
That's true in most cases of plugins. They compile their template output when the plugin is run, so you cannot access variables that are defined after compilation.

For s9y core templates this is different, because those are usually compiled at the end of the complete workflow, where templates themselves need to be 'finished' a whole lot earlier.

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/
Post Reply