WordPress.org

Support

Support » Plugins and Hacks » mobble » combining conditionals

combining conditionals

  • Hi

    Is it possible to combine mobble conditionals with wp conditionals? For example, I want to do something like this:

    <?php if (is_page_template('template-name.php') || (!is_mobile() || (!is_tablet())) { ?>
     code here
    <?php } ?>

    I tried using it and it didn’t work for me, is there a way to combine them?

    thanks

    http://wordpress.org/extend/plugins/mobble/

Viewing 15 replies - 1 through 15 (of 17 total)
  • Hi there, I have the same question…
    I used

    if (is_mobile()) { ... }
    else {... }

    But I am getting double content

    Plugin Author Scott (@scottsweb)

    @scottsweb

    Hi
    @intown Can you post your full code here. I think these two problems might be unrelated.

    In answer to @earthjibber – I think it is to do with the way your grouping your conditionals. Try one on each line and see how that goes.

    I had fixed the desktop problem, but still had the problem with iPad > i think is_mobile is also calling the iPad?

    <?php if (is_mobile()) {
                            $attr = array(
                            'title'	=> 'meer info over '.get_the_title(),
                            'width' => 390,
                            'height' => 'auto'
                        ); ?>
                    	<a href="<?php the_permalink(); ?>" title="Meer info over <?php the_title();?>"><?php the_post_thumbnail('medium', $attr); ?> <div class="clearer"></div></a>
                    <?php } ?>
    
                    <?php if (is_tablet()) {
                            $attr = array(
                            'title'	=> 'meer info over '.get_the_title(),
                            'width' => 187,
                            'height' => 256
                        ); ?>
                        <a href="<?php the_permalink(); ?>" title="Meer info over <?php the_title();?>"><?php the_post_thumbnail('small', $attr); ?> <div class="clearer"></div></a>
                    <?php } if ( !is_mobile() ) {
                            $attr = array(
                            'title'	=> 'meer info over '.get_the_title(),
                            'width' => 187,
                            'height' => 256
                        	); ?>
                        <a href="<?php the_permalink(); ?>" title="Meer info over <?php the_title();?>"><?php the_post_thumbnail('medium', $attr); ?> <div class="clearer"></div></a>
                	 <?php } ?>
    Plugin Author Scott (@scottsweb)

    @scottsweb

    Try this:

    <?php if (is_mobile()) { ?>
    					<?php $attr = array(
                            'title'	=> 'meer info over '.get_the_title(),
                            'width' => 390,
                            'height' => 'auto'
                        ); ?>
                    	<a href="<?php the_permalink(); ?>" title="Meer info over <?php the_title();?>"><?php the_post_thumbnail('medium', $attr); ?> <div class="clearer"></div></a>
    
                    <?php } else if (is_tablet()) { ?>
    					<?php $attr = array(
                            'title'	=> 'meer info over '.get_the_title(),
                            'width' => 187,
                            'height' => 256
                        ); ?>
                        <a href="<?php the_permalink(); ?>" title="Meer info over <?php the_title();?>"><?php the_post_thumbnail('small', $attr); ?> <div class="clearer"></div></a>
                    <?php } else { ?>
    					<?php $attr = array(
                            'title'	=> 'meer info over '.get_the_title(),
                            'width' => 187,
                            'height' => 256
                        	); ?>
                        <a href="<?php the_permalink(); ?>" title="Meer info over <?php the_title();?>"><?php the_post_thumbnail('medium', $attr); ?> <div class="clearer"></div></a>
                	 <?php } ?>

    Thank works perfect, thank you scott… I had been a late night that I couldn’t get through the conditional… I am deeply ashamed but you saved me!

    Plugin Author Scott (@scottsweb)

    @scottsweb

    My pleasure & good luck with the website 🙂

    Hi, is there a solution to the first question?

    How do you add several conditions together?

    Ie if is mobile device or tablet or … for example?

    Many thanks. Andrew

    Plugin Author Scott (@scottsweb)

    @scottsweb

    Sure. You should be able to group conditionals like so:

    if (is_mobile() || is_tablet()) {

    If its not detecting your current device, it may be because the detection library needs updating. Give this early release a try: https://github.com/scottsweb/mobble/archive/master.zip

    Let me know how you get on.

    Hi there,

    Thanks. That was how I had it but it wasn’t working with the tablet I have (Asus Google Nexus 7 with Jelly bean OS)

    I have tried your new library, but it still doesn’t seem to work. However, it does with my mobile (ios7)

    Any ideas? Cheers, Andrew

    I’m trying to get the ‘Ticker Tape’ Section of my website to not show on mobile and small screen devices as it scrolls the page down when it overflows.

    sailmakers

    Plugin Author Scott (@scottsweb)

    @scottsweb

    There are a couple of potential problems.

    1. Make sure your website does not use caching – any caching that skips PHP will not work with mobble.
    2. Give one of these a try:

    is_handheld() – to capture all handheld devices
    is_mobile() || is_tablet() || is_android – a tricky one as and you can also have Android based TVs these days – but it should work for the majority of use cases.

    Hmm, still not working.

    I thought it was because I had an exclamation mark on the first like so…

    if (!is_mobile() || is_tablet()) {

    But if I take this away, it stops working with the mobile.

    If I have t set as above, it works with the mobile, but not the tablet, if I take the exclamation mark away it doesnt work with the mobile, if I keep the exclamation mark and add any more that above it stops working with the mobile!…?

    Ok,

    using just…

    if (!is_handheld()) {…}

    seems to get it working on all devices. I guess I was having problems because I was trying to tell it NOT to do something, so that might change the way you list multiple conditions?

    Thanks for your help, A

    Plugin Author Scott (@scottsweb)

    @scottsweb

    Excellent. There is also an is_desktop() function which you may find useful too.

    Hi,

    Yes, to work at it the other way around!

    Many thanks, Andrew

Viewing 15 replies - 1 through 15 (of 17 total)
  • The topic ‘combining conditionals’ is closed to new replies.
Skip to toolbar