1 of 2
1
User Message Templates don’t work with JavaScript Disabled.
Posted: 17 July 2008 09:16 AM   [ Ignore ]  
Research Assistant
Avatar
RankRankRank
Total Posts:  845
Joined  10-14-2005

I think it would be preferable if the ‘User Message’ templates worked without JavaScript enabled.

At present the ‘Return to Previous Page’ link is written as a JavaScript history back-1, is there any reason for this? Could EE not get the referring URL instead, or at least use JavaScript in an unobtrusive manner?

<a href="http://www.referringurl.com">Return to Previous Page</a>

The href of the link could be returned as the ref URL and then the JavaScript could be applied as an onClick meaning that with JavaScript disabled the link would still function as expected.

:?

Edit: See here!

File Attachments
ext.noscript_messages.php.zip  (File Size: 3KB - Downloads: 158)
 Signature 

Nathan Pitman - Nine Four

Follow me on Twitter - Try my EE plug-ins and extensions

Profile
 
 
Posted: 22 July 2008 07:22 PM   [ Ignore ]   [ # 1 ]  
Lab Assistant
Avatar
RankRank
Total Posts:  235
Joined  11-01-2006

Agree

Profile
 
 
Posted: 23 July 2008 01:49 AM   [ Ignore ]   [ # 2 ]  
Research Assistant
Avatar
RankRankRank
Total Posts:  845
Joined  10-14-2005

Glad someone does! I’m a bit of an advocate for maintaining an ‘acceptable’ experience for users with JavaScript disabled. We’ve been working really hard on a current project using EE to do this. We’re using Thickbox to display ‘modal’ log-in and registration dialogs and this is the only thorn in our side, something we have no control over.

I’d be interested to hear from the EllisLab guys if this is something which could possibly be hacked. Even a pointer as to where to locate the code that generates that link would be useful. smile

 Signature 

Nathan Pitman - Nine Four

Follow me on Twitter - Try my EE plug-ins and extensions

Profile
 
 
Posted: 23 July 2008 04:36 PM   [ Ignore ]   [ # 3 ]  
Administrator
Avatar
RankRankRankRankRankRankRank
Total Posts:  19291
Joined  06-03-2002

While we can’t support hacks, I can understand the desire here.  /system/core/core.output.php, show_user_error().  Take care with how you choose to implement this, as show_message() will sanitize any links intended for the href= attribute of the link since this information can come from external sources.

 Signature 
Profile
MSG
 
 
Posted: 23 July 2008 04:38 PM   [ Ignore ]   [ # 4 ]  
Research Assistant
Avatar
RankRankRank
Total Posts:  845
Joined  10-14-2005

Thanks Derek, will let you know how I get on. Any chance that a future point release might see the default behavior (use of JavaScript) revised?

 Signature 

Nathan Pitman - Nine Four

Follow me on Twitter - Try my EE plug-ins and extensions

Profile
 
 
Posted: 23 July 2008 04:40 PM   [ Ignore ]   [ # 5 ]  
Administrator
Avatar
RankRankRankRankRankRankRank
Total Posts:  19291
Joined  06-03-2002

Yes, though not likely right away.

 Signature 
Profile
MSG
 
 
Posted: 23 July 2008 04:46 PM   [ Ignore ]   [ # 6 ]  
Research Assistant
Avatar
RankRankRank
Total Posts:  845
Joined  10-14-2005

Thanks. It’s enough to know that you understand where I’m coming from with this. smile

 Signature 

Nathan Pitman - Nine Four

Follow me on Twitter - Try my EE plug-ins and extensions

Profile
 
 
Posted: 24 July 2008 04:15 AM   [ Ignore ]   [ # 7 ]  
Research Assistant
Avatar
RankRankRank
Total Posts:  845
Joined  10-14-2005

Ok, unless I have missed anything, this seems dead easy to implement as a proper link. Here’s what I’ve done. At about line 536 in core.output.php I’ve added a var called ‘$ref_url’ which is the referring URL, I then add that to the data array in place of the nastyness that was the JavaScript history-1.

$ref_url = getenv("HTTP_REFERER");
        
        
$data = array(    'title'     => $LANG->line('error'),
                        
'heading'    => $heading,
                        
'content'    => $content,
                        
'redirect'    => '',
                        
'link'        => array($ref_url, $LANG->line('return_to_previous'))
                     );

Now try a search or whatever on your site and you’ll see your new ‘Return to Previous Page’ link except now it’s linked to a actual URL rather than using “[removed]history.go(-1)”. I’ve also tested this with login, logout and forgotton password to name a few and it all works as expected.

Obviously if anyone else tries this and discovers a problem please let me know.

 Signature 

Nathan Pitman - Nine Four

Follow me on Twitter - Try my EE plug-ins and extensions

Profile
 
 
Posted: 24 July 2008 04:27 AM   [ Ignore ]   [ # 8 ]  
Moderator
Avatar
RankRankRankRankRankRankRank
Total Posts:  29137
Joined  05-15-2004

What if there are no referrers? You can turn them off, and some servers do (or it gets stripped by firewalls or other network equipment or similar).

 Signature 

ExpressionEngine 2.0 Downloads | Docs | Bugtracker

“If the English language made any sense, lackadaisical would have something to do with a shortage of flowers.” (Doug Larson)

Profile
MSG
 
 
Posted: 24 July 2008 05:14 AM   [ Ignore ]   [ # 9 ]  
Research Assistant
Avatar
RankRankRank
Total Posts:  845
Joined  10-14-2005

What if the user has JavaScript disabled or it is not available? A server side solution is surely more robust isn’t it? At the end of the day there are always “what if’s”. The scenario you describe could easily be catered for by making the ‘default’ a JavaScript history-1 ‘onClick’ and the ref url in the href as the fall back? Just change line 471 in core.output.php to:

$data['link'] = "<a href='".$url."'>".$ltitle."</a>";

Problem solved. smile

Edit, JS got stripped out…, there was a ‘onClick’ after the href with a value of ‘history.go(-1); return false’.

 Signature 

Nathan Pitman - Nine Four

Follow me on Twitter - Try my EE plug-ins and extensions

Profile
 
 
Posted: 24 July 2008 05:31 AM   [ Ignore ]   [ # 10 ]  
Moderator
Avatar
RankRankRankRankRankRankRank
Total Posts:  29137
Joined  05-15-2004

I did not mean to imply that a JS-based solution was preferrable, just that—using PHP as we do—it would be possible, and in fact easy, to allow for a case where “HTTP_REFERER” was empty. Either by providing a JS-based fallback, a default link or something like that.

 Signature 

ExpressionEngine 2.0 Downloads | Docs | Bugtracker

“If the English language made any sense, lackadaisical would have something to do with a shortage of flowers.” (Doug Larson)

Profile
MSG
 
 
Posted: 24 July 2008 05:48 AM   [ Ignore ]   [ # 11 ]  
Research Assistant
Avatar
RankRankRank
Total Posts:  845
Joined  10-14-2005

Sure I know you were just playing devils advocate. raspberry

You’re right that there should be some validation of the ref_url value also in case there is no value so that the href is never empty. I think I’ll add that here. smile

 Signature 

Nathan Pitman - Nine Four

Follow me on Twitter - Try my EE plug-ins and extensions

Profile
 
 
Posted: 25 July 2008 04:05 AM   [ Ignore ]   [ # 12 ]  
Lab Assistant
Avatar
RankRank
Total Posts:  101
Joined  04-14-2006

What a great post..!

Profile
 
 
Posted: 18 September 2008 03:02 PM   [ Ignore ]   [ # 13 ]  
Research Assistant
Avatar
RankRankRank
Total Posts:  845
Joined  10-14-2005
Paul Cripps (Nine Four) - 25 July 2008 04:05 AM

What a great post..!

You would say that! wink

Here I am re-applying my hacks after an upgrade from 1.6.3 to 1.6.4! Something worth noting, I’ve started adding a file to the root of my EE sites called ‘hacks.txt’ which contains a plain text list of hacks and the related forum entries so that when I come back to perform an upgrade, I have a definitive list of what hacks I need to be wary of.

 Signature 

Nathan Pitman - Nine Four

Follow me on Twitter - Try my EE plug-ins and extensions

Profile
 
 
Posted: 18 September 2008 03:35 PM   [ Ignore ]   [ # 14 ]  
Administrator
Avatar
RankRankRankRankRankRankRank
Total Posts:  19291
Joined  06-03-2002

Nathan, you can use an extension and eliminate a hack here.  Use the System Offline extension as a template.

 Signature 
Profile
MSG
 
 
Posted: 18 September 2008 03:54 PM   [ Ignore ]   [ # 15 ]  
Research Assistant
Avatar
RankRankRank
Total Posts:  845
Joined  10-14-2005

Huh? Sorry.. confused… :?

 Signature 

Nathan Pitman - Nine Four

Follow me on Twitter - Try my EE plug-ins and extensions

Profile
 
 
Posted: 18 September 2008 03:57 PM   [ Ignore ]   [ # 16 ]  
Administrator
Avatar
RankRankRankRankRankRankRank
Total Posts:  19291
Joined  06-03-2002

Instead of hacking core.output.php, you can override the global $OUT object with an extended version of the class, so your extension will basically just rewrite the show_message() method to do whatever you want.  And you’ll be able to keep core.output.php intact and in step with the release.

 Signature 
Profile
MSG
 
 
Posted: 18 September 2008 04:55 PM   [ Ignore ]   [ # 17 ]  
Research Assistant
Avatar
RankRankRank
Total Posts:  845
Joined  10-14-2005

Ah, sorry I see what you are suggesting now. Thanks for the prod in the right direction Derek, let me know if this works for you…

http://nathanpitman.com/journal/551/expressionengine-extension-noscript-messages

smile

 Signature 

Nathan Pitman - Nine Four

Follow me on Twitter - Try my EE plug-ins and extensions

Profile
 
 
Posted: 19 September 2008 08:58 AM   [ Ignore ]   [ # 18 ]  
Administrator
Avatar
RankRankRankRankRankRankRank
Total Posts:  19291
Joined  06-03-2002

I don’t have time at the moment to try it out, Nathan, but at a glance it looks good, i.e. you’re using the hook correctly.  The only issue of course is that this extension and the System Offline extension cannot be installed at the same time, as they each overwrite the global $OUT object with their own version of the class, though it’s a trivial matter for someone to merge the methods that they wish overwritten into a single extension.

 Signature 
Profile
MSG
 
 
   
1 of 2
1
 
Post Marker Legend
New Topic New posts Hot Topic Hot Topic with new posts New Poll New Poll Moved Topic Moved Topic Sticky Topic Sticky topic
Old Topic No new posts Hot Old Topic Hot Topic with no new posts Old Poll Old Poll Closed Topic Closed Topic Announcement Announcements
Theme
Change Theme
Visitor Statistics
The most visitors ever was 1743, on December 02, 2009 03:47 PM
Total Registered Members: 120195 Total Logged-in Users: 93
Total Topics: 126322 Total Anonymous Users: 46
Total Replies: 664349 Total Guests: 437
Total Posts: 790671    
Members ( View Memberlist )