Go Back   vb.org Archive > vBulletin 4 Discussion > vB4 General Discussions
  #1  
Old 04-09-2013, 03:42 PM
keyness keyness is offline
 
Join Date: Oct 2006
Posts: 63
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default Change Header Depending to Screen Size

Hello,

I designed a header for 1280 and above screen width. But when screen width is below than 1280 pixels, it doesn't look well. So I want to change header depending to user's screen width.

I tried something like that in header template, but it didn't work:

<vb:if condition="screen.width <= '1280'">

Header code for above 1280px

</else>

Header code for below 1280px

</vb:if>

Where I am mistaken?
Reply With Quote
  #2  
Old 04-09-2013, 05:25 PM
Christos Teriakis Christos Teriakis is offline
 
Join Date: Jul 2011
Location: Thessaloniki, Greece
Posts: 1,228
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by keyness View Post
Hello,

I designed a header for 1280 and above screen width. But when screen width is below than 1280 pixels, it doesn't look well. So I want to change header depending to user's screen width.

I tried something like that in header template, but it didn't work:

<vb:if condition="screen.width <= '1280'">

Header code for above 1280px

</else>

Header code for below 1280px

</vb:if>

Where I am mistaken?
Without testing your code, the only that I can say is that you've a syntax error:
is: <vb:else /> and not </else>

Edited: But I've doubts for your condition. Where did you found that screen.width . If it's a global variable you must use the sign $ before. eg: $screen.width

Chris
Reply With Quote
  #3  
Old 04-09-2013, 05:29 PM
keyness keyness is offline
 
Join Date: Oct 2006
Posts: 63
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Oh, that's right, I'll try it. Thank you Chris!

By the way, after asked this question I managed to do it with iframe like this:
Code:
<script type="text/javascript">
if (screen.width<=1280)
{
 document.write('<iframe src="headersm.php" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:100%; height:260px;"></iframe>');
}
else
{
 document.write('<iframe src="headerbig.php" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:100%; height:260px;"></iframe>');
}
</script>
However, without iframe it would be better of course.
Reply With Quote
  #4  
Old 04-09-2013, 05:33 PM
Christos Teriakis Christos Teriakis is offline
 
Join Date: Jul 2011
Location: Thessaloniki, Greece
Posts: 1,228
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Also change $screen.width <= '1280' to screen.width <= 1280
Reply With Quote
  #5  
Old 04-09-2013, 05:37 PM
keyness keyness is offline
 
Join Date: Oct 2006
Posts: 63
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Dear Chris,

Where to put that code inside headinclude template in your following solution: (I mean at the end or at the beginning of code)

https://vborg.vbsupport.ru/showpost....82&postcount=8

--------------- Added [DATE]1365532959[/DATE] at [TIME]1365532959[/TIME] ---------------

Quote:
Originally Posted by ChrisTERiS View Post
Also change $screen.width <= '1280' to screen.width <= 1280
It worked as a charm when I did this. I never thought it could effect it.

Thank you Chris!

In order to help people who will find this page via search engines for same intention I share the code:

Code:
<vb:if condition="screen.width <= 1280">

Code if screen width is smaller than 1280

<vb:else/>

Code if screen width is bigger than 1280

</vb:if>
Reply With Quote
  #6  
Old 04-09-2013, 06:35 PM
RedTurtle's Avatar
RedTurtle RedTurtle is offline
 
Join Date: May 2006
Location: California
Posts: 205
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Thank you so much for this thread. I am trying to do something similar.

I created a plugin that hooks into global_setup_complete and determines when to show a second advertisement on my forum to a guest visitor. Currently it is setup to only show a second advert if the user is not using a tablet or a phone to view the page. I would also like to add the check for screen width at the plugin level.

I have the following code:

Code:
global $vbulletin, $show;
//If the user isn't using a phone or tablet to view the site, show the second advertisement.
if (!$vbulletin->detect->isMobile() AND !$vbulletin->detect->isTablet() ){
$show['second_header_ad'] = true;
}
How can I modify this to also check screen width?

Thank you!
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 01:52 AM.


Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2024, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.04572 seconds
  • Memory Usage 2,210KB
  • Queries Executed 13 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)ad_showthread_beforeqr
  • (1)ad_showthread_firstpost
  • (1)ad_showthread_firstpost_sig
  • (1)ad_showthread_firstpost_start
  • (3)bbcode_code
  • (2)bbcode_quote
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (6)post_thanks_box
  • (6)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (6)post_thanks_postbit_info
  • (6)postbit
  • (6)postbit_onlinestatus
  • (6)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available:
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files:
  • ./showthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_post_thanks.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_postinfo_query
  • fetch_postinfo
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • showthread_start
  • showthread_getinfo
  • forumjump
  • showthread_post_start
  • showthread_query_postids
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • postbit_display_start
  • post_thanks_function_post_thanks_off_start
  • post_thanks_function_post_thanks_off_end
  • post_thanks_function_fetch_thanks_start
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • fetch_musername
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete