1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

What if conditional methode to do this? please help

Discussion in 'PHP' started by basketmen, May 16, 2015.

  1. #1
    i have responsive template, its have 3 php files :

    - templatedesktop.php : template file for desktop

    - templatemobile.php : template file for mobile


    - page.php : contain information content, its included templatedesktop.php & templatemobile.php file inside

    now i need to hide some part inside page.php, that should hide from mobile version, and appeared in desktop version only


    i already tried add this define code inside templatedesktop.php file :
    and wrap some part that want to hide
    but its not working, maybe its should do the opposite, please help what is the right if conditional/methode? like request, referer or other
     
    basketmen, May 16, 2015 IP
  2. PoPSiCLe

    PoPSiCLe Illustrious Member

    Messages:
    4,623
    Likes Received:
    725
    Best Answers:
    152
    Trophy Points:
    470
    #2
    First of, I don't understand why the responsive template needs to include two files for different purposes at the same time - I don't even understand how this works - how does it discern what to show from templatemobile and templatedesktop at any given time? This sounds like a very hacked-together solution.
    Second: if this works as I assume it should work, why can't you just add the content you need to display for desktop only in the templatedesktop file?
     
    PoPSiCLe, May 16, 2015 IP
  3. basketmen

    basketmen Well-Known Member

    Messages:
    837
    Likes Received:
    6
    Best Answers:
    0
    Trophy Points:
    130
    #3
    its responsive, its can detect visitors using desktop or mobile & select which template file will used

    because the content need to hide is inside page.php file, and the template is in different files, templatedesktop.php and templatemobile.php

    there is should be a php conditional to do this, which one to do this http://php.net/manual/en/reserved.variables.server.php
     
    basketmen, May 16, 2015 IP
  4. Anveto

    Anveto Well-Known Member

    Messages:
    697
    Likes Received:
    40
    Best Answers:
    19
    Trophy Points:
    195
    #4
    Have you tried just using a variable?

    
    $isdesktop = true;
    if ($isdesktop) {
        //Show desktop stuff
    }
    
    PHP:
    Have you tried echoing THIS_SCRIPT to see if it is defined in different places of your script?

    Anyways, you would probably be much better off using CSS media queries as described here https://developer.mozilla.org/en-US/docs/Web/Guide/CSS/Media_queries

    Then you can hide or show different parts of the page depending on screen size. Just do display:none; to hide a div for example.
     
    Anveto, May 16, 2015 IP
  5. PoPSiCLe

    PoPSiCLe Illustrious Member

    Messages:
    4,623
    Likes Received:
    725
    Best Answers:
    152
    Trophy Points:
    470
    #5
    The solution used is incredibly stupid. Depending on what it utilizes to check what kind of browser the user have, it will break at some point. What exactly does the different template-files contain? To me, the whole setup reeks of incompetent developers. Sorry to say it, but the solution provided for a non-existing problem is horribly bad.
     
    PoPSiCLe, May 16, 2015 IP
    deathshadow likes this.
  6. Anveto

    Anveto Well-Known Member

    Messages:
    697
    Likes Received:
    40
    Best Answers:
    19
    Trophy Points:
    195
    #6
    The implementations I have seen do this via user agent which is never going to be a perfect solution. Something like mobiledetect.net can be used for this but I would never use it for site layouts. It may be an option to present targeted advertising or something similar.
     
    Anveto, May 16, 2015 IP
  7. deathshadow

    deathshadow Acclaimed Member

    Messages:
    9,732
    Likes Received:
    1,998
    Best Answers:
    253
    Trophy Points:
    515
    #7
    I've seen this particular bit of asshattery returning from the 1990's (like every other bit of stupidity) in part because Google's webmaster tools/suggestions is now advocating it in their utter and complete ignorance and newly found scam artist bullshit of trying to make you build a crappy page so you 'need' their pageSpeed "service". (which has been doing a stellar job of "servicing" people in the same way a bunk-mate in prison would)

    Let's call this what it is as this type of mouth-breathing dumbass nonsense is NOT RESPONSIVE DESIGN -- IT'S BROWSER SNIFFING. THE ENTIRE POINT of responsive design is to have ONE UNIFIED MARKUP and then use media queries to change the layout! (Playing to the original intent of HTML and why it exists, one markup for ALL possible device capabilities and combinations!) If you are using different markup, it's not responsive! Do not pass start, do not collect. If you need to have two different PHP includes just for a "responsive" design, you don't know what responsive layout is, much less how to build one!

    Which probably means you don't grasp accessibility minimums, elastic semi-fluid design, separation of presentation from content, when not to use pointless scripttardery, or any of the dozens of stepping stones one should have traveled BEFORE even THINKING about responsive design.
     
    Last edited: May 17, 2015
    deathshadow, May 17, 2015 IP