- This topic has 11 replies, 2 voices, and was last updated 6 years, 11 months ago by
Tom.
-
AuthorPosts
-
October 29, 2018 at 12:47 pm #713489
Todd
At the bottom of the URL I’ve attached I have logos that I am NOT displaying using the built-in hide-on-mobile glass. Is there a technique or a way to hide this and also keep the content from loading on the devices it is hidden on?
October 29, 2018 at 6:13 pm #713745Tom
Lead DeveloperLead DeveloperIt might be possible to check what kind of device your visitor is using with PHP, but I’m not really sure of a good way to do it.
You’d have to find a good way to check and then display those logos inside a shortcode or something similar so you could return false/empty if the user isn’t on a mobile device.
October 29, 2018 at 9:37 pm #713838Todd
I revised the link in the the first post for I am trying to get something to work on a test page.
This inspired me to try and find a PHP solution. At the bottom of my test URL, I am trying to display the logos with a different hook. Unfortunately, I think I’m just hacking my way through the PHP. At the top of the page it is echoing some text based on mobile or desktop from another hook so I am getting somewhere…I think.
I have tried putting the following PHP that calls upon the same PHP hook from this solution I found on this post.
My PHP is as follows, it seems that no matter how I write it it creates an error I’ve also tried putting it in a short code and the trying to figure out how to Echo the short code and that did not work.
<?php
if(isMobileDevice()){
//Your content or code for mobile devices goes here
}
else {
//Your content or code for desktop or computers devices<hr />
<h2>Our Clients</h2>
[logoshowcase show_title=”false” image_size=”full” extra_class=”logo-showcase-footer-2″ slides_column=”6″ dots=”false” arrows=”false” autoplay_interval=”4000″ cat_id=”1925″]}
October 30, 2018 at 8:53 am #714502Tom
Lead DeveloperLead DeveloperSo, assuming you’ve defined
isMobileDevice()
somewhere, you would do this:<?php if ( ! isMobileDevice() ) : ?> Your HTML in here <?php endif;
October 30, 2018 at 7:12 pm #715075Todd
I tried that and it is giving me an error at bottom of the page. In general it does seem to be working, since the following code in another hook seems to make the header at the top appear on this testing page.
<?php if(isMobileDevice()){ echo "It is a mobile device"; } else { echo "It is desktop or computer device"; } ?>
October 31, 2018 at 10:02 am #715736Tom
Lead DeveloperLead DeveloperWhat was the error?
October 31, 2018 at 10:49 am #715780Todd
I put the link in the original post thread, it is at the bottom where I have the hook trying to display and it is the following:
Parse error: syntax error, unexpected '<', expecting end of file in /home/curious9/public_html/tvtg164363/wp-content/plugins/gp-premium/elements/class-hooks.php(180) : eval()'d code on line 6
October 31, 2018 at 5:02 pm #716017Tom
Lead DeveloperLead DeveloperTry this:
<?php if ( ! isMobileDevice() ) : ?> Your HTML in here <?php endif; ?>
October 31, 2018 at 7:30 pm #716069Todd
I can get the following Ex 1 to work as a test and it is working as a hook at the top of the page. I just can not figure out how to do the same thing with a more complicated block of html as you see in Ex 2 without an error, it seems the class quotes are conflicting with the PHP?
Also in Example 2, if I want nothing to appear in mobile do I just echo blank quotes?
Example 1: Works as a test
<?php if(isMobileDevice()){ echo "<div><h2>This is a mobile device</h2></div>"; } else { echo "<div><h2>It is desktop or computer device</h2></div>"; } ?>
Example 2: causes an error in italics
<?php if(isMobileDevice()){ echo ""; } else { echo "<div class="hide-on-mobile grid-container logo-showcase-footer-1"> <hr /> <h2>Our Clients</h2> [logoshowcase show_title="false" image_size="full" extra_class="logo-showcase-footer-2" slides_column="6" dots="false" arrows="false" autoplay_interval="4000" cat_id="1925"]</div>"; } ?>
Parse error: syntax error, unexpected ‘hide’ (T_STRING), expecting ‘,’ or ‘;’ in /home/searcht1/public_html/vortechsgroup.com/wp-content/plugins/gp-premium/elements/class-hooks.php(180) : eval()’d code on line 6
November 1, 2018 at 9:49 am #716593Tom
Lead DeveloperLead DeveloperDo this instead:
<?php if ( isMobileDevice() ) { echo ""; } else { ?> Your HTML in here. <?php } ?>
November 1, 2018 at 12:12 pm #716680Todd
Tom, this fantastic, I got this to work and this solves a problem for me. I just sent a donation, not much but I sure appreciate your service and patience. Thank you.
November 1, 2018 at 4:16 pm #716837Tom
Lead DeveloperLead DeveloperThanks so much! I really appreciate it 🙂
-
AuthorPosts
- You must be logged in to reply to this topic.