mobile extension + weblogs

Discuss PivotX 2.0.x extensions here, and view extensions that are available for download.

mobile extension + weblogs

Postby draekko » Mon Jul 09, 2012 2:29 pm

Long time Pivotx user, first time poster :D don't hang me if i'm breaking a rule or two :P

Just posting a modification to the mobile extension and a mod to the forms.php file to let each weblog have a different mobile template same as for the regular site. Created this because i needed a way to handle several languages both in mobile and the regular site. This based off of v2.3.3 for forms.php and whatever latest mobile extension was online as of yesterday. To use it just replace the files currently installed. I left the original way that the mobile extension worked intact so that if no templates are set for the weblog it will default back to whatever is default for the extension. I can post some diff patches if need be later today or whenever.

http://draekko.com/files/mobile.zip

Enjoy.
draekko
 
Posts: 2
Joined: Mon Jul 09, 2012 2:03 pm

Re: mobile extension + weblogs

Postby jadwigo » Wed Jul 11, 2012 12:32 pm

This looks useful.

I would recommend that you move the settings for the mobile templates to a separate page that is managed inside the snippet_mobile.php file. That way the core pivotx forms won't need to be changed.

If you add the following example code to snippet_mobile.php this will add a new tab to your Configuration page with the fields you added.

Code: Select all

$this->addHook(
    'configuration_add',
    'mobile',
    array('mobile_templates_form', __('Mobile templates'))
);

function mobile_templates_form(&$form_html)
{
    global $PIVOTX;

    $templates= templateList();

    $form = new Form("mobiletemplates", "", __("Save"));

    // No border and no 'submit' for this form:
    $form->html['start'] = <<< EOM
<form  enctype='multipart/form-data'  name='%name%' id='%name%' action="%action%" method='post'>
<table border='0' cellspacing='0' cellpadding='4' class='formclass' style="border-width: 0px !important;">
EOM;
    $form->html['submit'] = "";

    $form->add( array(
        'type' => "csrf",
        'cookie' => "pivotxsession",
        'sessionvariable' => "pivotxsession"
    ));

    $form->add( array(
        'type' => 'custom',
        'text' => "<tr><td colspan='2'><h3>".__('Mobile Templates')."</h3></td></tr>"
    ));

    $templateoptions = templateOptions($templates, 'mobile_front', array('_sub_', '_aux_'));

    $form->add( array(
        'type' => 'select',
        'name' => 'mobile_front_template',
        'label' => __('Frontpage Template'),
        'value' => '',
        'options' => $templateoptions,
        'text' => makeJtip(__('Frontpage Template'), __('The Template which determines the layout of the index page of this weblog.'))
    ));


    $templateoptions = templateOptions($templates, 'mobile_archive', array('_sub_', '_aux_'));

    $form->add( array(
        'type' => 'select',
        'name' => 'mobile_archivepage_template',
        'label' => __('Archivepage Template'),
        'value' => '',
        'options' => $templateoptions,
        'text' => makeJtip(__('Frontpage Template'), __('The Template which determines the layout of your archives. This can be the same as "Frontpage Template".'))
    ));


    $templateoptions = templateOptions($templates, 'mobile_entry', array('_sub_', '_aux_'));

    $form->add( array(
        'type' => 'select',
        'name' => 'mobile_entry_template',
        'label' => __('Entrypage Template'),
        'value' => '',
        'options' => $templateoptions,
        'text' => makeJtip(__('Entrypage Template'), __('The Template which determines the layout of single entries.'))
    ));

    $templateoptions = templateOptions($templates, array('mobile_search','extra'), array('_sub_', '_aux_'));

    $form->add( array(
        'type' => 'select',
        'name' => 'mobile_extra_template',
        'label' => __('Extra Template'),
        'value' => '',
        'options' => $templateoptions,
        'text' => makeJtip(__('Extra Template'), __('The Template that defines how a search, tag or other special page will look like.'))
    ));

    $templateoptions = templateOptions($templates, 'mobile_page', array('_sub_', '_aux_'));

    $form->add( array(
        'type' => 'select',
        'name' => 'mobile_page_template',
        'label' => __('Page Template'),
        'value' => '',
        'options' => $templateoptions,
        'text' => makeJtip(__('Page Template'), __('The Template that defines how a page will look like if you haven\'t specified a template for it.'))
    ));

    $form->use_javascript(true);

    return $form;
}
My pivotx playground is at http://jivotx.twokings.eu - the rest is at http://www.jadwigo.nl
jadwigo
Developer
 
Posts: 117
Joined: Wed Nov 18, 2009 9:49 am
Location: Den Haag, Netherlands

Re: mobile extension + weblogs

Postby draekko » Wed Jul 11, 2012 4:46 pm

Personnaly i'd rather handle each weblog as is for both mobile & regular sites so i only have to go to 1 place to set up both for each instances. I already feel that the settings are scattered all over (too many tabs lol). But i'll take a look at this later today or tomorrow and see how it works. Thanks :)
draekko
 
Posts: 2
Joined: Mon Jul 09, 2012 2:03 pm


Return to 2.x Extensions

Who is online

Users browsing this forum: No registered users and 2 guests

cron