Forums / Developer / Resolution check

Resolution check

Author Message

Pål Messenlien

Thursday 18 January 2007 3:13:10 pm

Im trying to remove a flash from our mainpage if the resolution is lower than 800x600

<script type="text/javascript" language="javascript">
<!--
	var width = screen.width
	var height = screen.height
	if (width > 800)
		document.write("{def $visflash = yes}");
	else {ldelim}
		document.write("&nbsp;Your screen resolution is set to "+width+ "x" +height+".  This site is best when viewed at 800x600 or greater.</B><BR>");
	{rdelim}
//-->
</script>

And this is what i use to check and show the flash

{if is_set( $visflash )}
   {let flash=fetch(content,node,hash(node_id,5863))}
			{node_view_gui view=full content_node=$flash}
		{/let}
{else}
    It is not set.
{/if}

The check returns right, but still $visflash returns true.

--------------------------------------------
Høgskolen i Lillehammer
Lillehammer University College
http://www.hil.no
--------------------------------------------
Messenlien IT
http://messenlien.com
-------------------------------------------

kracker (the)

Thursday 18 January 2007 4:21:32 pm

I would modify your direction to include,
a javascript check which shows the user
and offers a choice / solution.

Perhaps exposes a url or does a redirirection
to eZ and setts a session variable or something ....

You want to pass a variable back to eZ (in
one of many ways possible). Which
returns to the user the modifed, view
as needed?

Because trying to set a template variable
at the end of each requqest via javascript,
yet evaluate the variable during the start
of each request which just simply won't
work.

Instead use a variable which can
be passed from javascript to eZ publish,
perhaps using a url argument.

hth,
//kracker

it makes sense from a certain point of view.

Member since: 2001.07.13 || http://ezpedia.se7enx.com/

Bruce Morrison

Thursday 18 January 2007 5:38:59 pm

Hi Pål

The reason you code is not producing the desired result is that the javascript is generating eZ template code.

The basic order of the process is:

1. User results URL
2. eZ does it's magic and generates html from combining the content and 3. templates.
4. HTML is read by browser
5. Any javascript is run in the browser

Your code will just write the text template code into the HTML in the users browser. It's not happening in the right place in the process.

Some suggestions:
+ Display the flash for all users but use javascript to hide (via CSS) or remove the flash from the HTML if the screen width < 800

+ If the screen width > 800 use AJAX to retrieve the code for the banner and add it in the HTML using javascript.

Cheers
Bruce

My Blog: http://www.stuffandcontent.com/
Follow me on twitter: http://twitter.com/brucemorrison
Consolidated eZ Publish Feed : http://friendfeed.com/rooms/ez-publish

Pål Messenlien

Friday 19 January 2007 12:27:56 pm

Thanks alot guys.
I see now i need to get me some better basic javascript knowledge. Been stealing code to long:)

The flash mentioned here is something thats being placed on the frontpage of our website. The reason i want remove it is cause it breaks the design in lower resolutions. Damn marketing people! Making a redirection url or refresh of page with a variable would work, but its not something that looks good. I prefer the user with lower resolution to not see the flash at all since it dont have any other function than being fancy. Hiding it with css would work, but then the user downloads 200k of something he cant see, and the flash would be visible when removing styles on the page.

The ajax solution sounds like something that would work, but i dont have enough knowledge about ajax todo it.

I came up with another solution after some googling:
http://www.zimmertech.com/tutorials/javascript/21/page-resolution-detector-tutorial.php

Could i use a cookie instead maybe?.. I have tought a litle about making the site resolution dependent, not only the layout and design, but maybe move some ez items around.

Will dig into what i have for now, but more suggestions (and example code) are welcome:)

--------------------------------------------
Høgskolen i Lillehammer
Lillehammer University College
http://www.hil.no
--------------------------------------------
Messenlien IT
http://messenlien.com
-------------------------------------------

Nicolas Lescure

Saturday 20 January 2007 5:29:40 am

Hi.

You know, noone use resolution under 800*600 today... Even 800*600 is not very used.
If you don't want the flash without CSS, you can try a javascript that remove the flash object when the page is loaded.
But ok, they have downloaded it... it is not really a problem for 0.1% (maybe) of users.

Pål Messenlien

Saturday 20 January 2007 3:54:48 pm

We have 1% users using 800x600 or lower on the webpage. During a month thats about 1000 users. These users are often blind and reading the page with a special software or other equipment. The goal is to make the webpage accesible to these also. I think the css removal should do the trick untill i find something better.

--------------------------------------------
Høgskolen i Lillehammer
Lillehammer University College
http://www.hil.no
--------------------------------------------
Messenlien IT
http://messenlien.com
-------------------------------------------

eZ debug

Timing: Jan 31 2025 00:35:24
Script start
Timing: Jan 31 2025 00:35:24
Module start 'content'
Timing: Jan 31 2025 00:35:24
Module end 'content'
Timing: Jan 31 2025 00:35:24
Script end

Main resources:

Total runtime0.2211 sec
Peak memory usage8,192.0000 KB
Database Queries141

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0088 587.8125370.3047
Module start 'content' 0.00880.0129 958.11721,009.6094
Module end 'content' 0.02170.1994 1,967.72663,898.3984
Script end 0.2211  5,866.1250 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00452.0378200.0002
Check MTime0.00130.6057200.0001
Mysql Total
Database connection0.00130.601910.0013
Mysqli_queries0.124656.35081410.0009
Looping result0.00130.59441390.0000
Template Total0.198990.010.1989
Template load0.00080.369010.0008
Template processing0.198189.581810.1981
Override
Cache load0.00050.239710.0005
Sytem overhead
Fetch class attribute can translate value0.00190.876810.0019
XML
Image XML parsing0.00020.097110.0002
General
dbfile0.00813.6754200.0004
String conversion0.00000.002330.0000
Note: percentages do not add up to 100% because some accumulators overlap

CSS/JS files loaded with "ezjscPacker" during request:

CacheTypePacklevelSourceFiles
CSS0extension/community/design/community/stylesheets/ext/jquery.autocomplete.css
extension/community_design/design/suncana/stylesheets/scrollbars.css
extension/community_design/design/suncana/stylesheets/tabs.css
extension/community_design/design/suncana/stylesheets/roadmap.css
extension/community_design/design/suncana/stylesheets/content.css
extension/community_design/design/suncana/stylesheets/star-rating.css
extension/community_design/design/suncana/stylesheets/syntax_and_custom_tags.css
extension/community_design/design/suncana/stylesheets/buttons.css
extension/community_design/design/suncana/stylesheets/tweetbox.css
extension/community_design/design/suncana/stylesheets/jquery.fancybox-1.3.4.css
extension/bcsmoothgallery/design/standard/stylesheets/magnific-popup.css
extension/sevenx/design/simple/stylesheets/star_rating.css
extension/sevenx/design/simple/stylesheets/libs/fontawesome/css/all.min.css
extension/sevenx/design/simple/stylesheets/main.v02.css
extension/sevenx/design/simple/stylesheets/main.v02.res.css
JS0extension/ezjscore/design/standard/lib/yui/3.17.2/build/yui/yui-min.js
extension/ezjscore/design/standard/javascript/jquery-3.7.0.min.js
extension/community_design/design/suncana/javascript/jquery.ui.core.min.js
extension/community_design/design/suncana/javascript/jquery.ui.widget.min.js
extension/community_design/design/suncana/javascript/jquery.easing.1.3.js
extension/community_design/design/suncana/javascript/jquery.ui.tabs.js
extension/community_design/design/suncana/javascript/jquery.hoverIntent.min.js
extension/community_design/design/suncana/javascript/jquery.popmenu.js
extension/community_design/design/suncana/javascript/jScrollPane.js
extension/community_design/design/suncana/javascript/jquery.mousewheel.js
extension/community_design/design/suncana/javascript/jquery.cycle.all.js
extension/sevenx/design/simple/javascript/jquery.scrollTo.js
extension/community_design/design/suncana/javascript/jquery.cookie.js
extension/community_design/design/suncana/javascript/ezstarrating_jquery.js
extension/community_design/design/suncana/javascript/jquery.initboxes.js
extension/community_design/design/suncana/javascript/app.js
extension/community_design/design/suncana/javascript/twitterwidget.js
extension/community_design/design/suncana/javascript/community.js
extension/community_design/design/suncana/javascript/roadmap.js
extension/community_design/design/suncana/javascript/ez.js
extension/community_design/design/suncana/javascript/ezshareevents.js
extension/sevenx/design/simple/javascript/main.js

Templates used to render the page:

UsageRequested templateTemplateTemplate loadedEditOverride
1pagelayout.tpl<No override>extension/sevenx/design/simple/templates/pagelayout.tplEdit templateOverride template
 Number of times templates used: 1
 Number of unique templates used: 1

Time used to render debug report: 0.0002 secs