Navigation

Pligg Support

Hi,
I would like to add to my pligg site a Mobiledetect script :
https://github.com/serbanghita/Mobile-Detect
It's because the changes I want to make in link_summary.tpl for mobile devices are too hardcore for a normal CSS media query manipulations.
I want to make additional story template for mobile and name it 'link_summary_mobile.tpl'.

Then I will check the device type and apply appropriate link_summary.tpl or link_summary_mobile.tpl accordingly.

But I have difficulties in finding where link_summary.tpl is actually included (in story_center.tpl there is a variable called {$the_story}, but I can't find the source )

I would be very grateful for any help
Thank you
Karol

Possible Answers

    It may be easier to create a completely separate template and then push the mobile users to that template using detect and php header redirect in the main template head..

    yoursite/settemplate.php?template=mobile_template_name

    | Posted 67 days ago | Permalink | Hide Replies

    Ok, so I managed to do it in more optimal way as I wanted by copying file 'Mobile_Detect.php' to 'libs' folder and adding couple of lines to 'link.php' which is in the same folder. These are my lines 431 - 445:

    function print_summary($type='full', $fetch = false, $link_summary_template = 'link_summary.tpl') {

    global $current_user, $globals, $the_template, $smarty, $ranklist, $db;

    require_once 'Mobile_Detect.php';

    $detect = new Mobile_Detect;

    $deviceType = ($detect->isMobile() ? ($detect->isTablet() ? 'tablet' : 'phone') : 'computer');

    if ( $deviceType == 'phone' ) {

    $link_summary_template = 'link_summary_mobile.tpl';

    }

    // DB 09/03/08

    if(!is_numeric($this->id)){return false;}

    /////

    include_once('../internal/Smarty.class.php');

    $main_smarty = new Smarty;

    $main_smarty->assign('deviceType', $deviceType);

    I added script for device detection, and assigned smarty variable for validation purposes or whatever it may be useful for.

    If somebody wants to check for tablet device and write a separate link_summary_tablet.tpl template you can do it by adding another conditional such as:

    elseif ( $deviceType == 'tablet' ) {

    $link_summary_template = 'link_summary_tablet.tpl';

    }

    And I added code below to link_summary.tpl and to link_summary_mobile.tpl for my validation purpose. It shows me if the type of device was properly detected:

    {if $isadmin eq 'yes'}{$deviceType}{/if}

    It works perfectly for me so I think I will leave it that way and hope it won't give me any troubles.

    Use it if you want it.

    If anybody finds a bug there please reply here.

    Thanks

    | Posted 66 days ago | Permalink | Hide Replies

Who Upvoted this Story

Pligg.com's Support area is where you can ask questions and get answers. Just getting started with the Support area? This section describes tips for participating.

Submitting a Question or Comment

By taking a minute to research previous posts you may receive an answer much faster than waiting for a response to a new question. Begin by searching the support section for an answer. Sometimes you may even want to extend your search to the entire pligg.com domain.

If you are unable to find a relevant answer, submit a new question or comment here. Please provide a detailed description and, when necessary, debugging information such as your server environment (a link to a <?php phypinfo(); ?> .php page would be very helpful), your web browser, and any steps necessary to reproduce your issue.

Submitting an Answer

If you have an answer or useful response that you would like to add to a post, you can submit it as a comment which other users will then vote on. Answers are sorted by most popular to least, allowing the best information to climb to the top of the page.

Please read and vote for existing answers before submitting your own, as there may already be an acceptable answer provided. You can use the "Reply" link found within an answer to submit a response to it, in case you want to expand or comment on someone else's contribution.

Including Files or Code

Sometimes it is necessary for you to attach a file or include a snippet of code for others to reference in your response. In most cases, you can .zip up files and attach them to a question or answer using Pligg's file manager. At times though this may fail, and in these circumstances we recommend using a third party host. Below we are including a list of recommended websites where you can share easily share file uploads (or snippets of code) through the web.