Skip to content
This repository was archived by the owner on Oct 30, 2021. It is now read-only.

Commit 3c41414

Browse files
committed
Integrate mobile view switch
Change viewDesktop to desktop
1 parent ae8e334 commit 3c41414

File tree

8 files changed

+31
-8
lines changed

8 files changed

+31
-8
lines changed

elements/logic.php

+1
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636
$default = $menu->getActive() == $menu->getDefault($lang->getTag());
3737

3838
// Define shortcuts for template parameters
39+
$allowMobileUrl = $this->params->get('allowMobileUrl');
3940
$customStyleSheet = $this->params->get('customStyleSheet');
4041
$customStyleSheetVersion = htmlspecialchars($this->params->get('customStyleSheetVersion'));
4142
$detectTablets = $this->params->get('detectTablets');

index.php

+12-3
Original file line numberDiff line numberDiff line change
@@ -28,12 +28,21 @@
2828
$results = $layoutOverride->getIncludeFile();
2929

3030
// Check if mobile device has opted for desktop version
31-
if (isset($_GET['viewDesktop'])) {
32-
$_SESSION['viewDesktop'] = $_GET['viewDesktop'];
31+
if (isset($_GET['desktop'])) {
32+
$_SESSION['desktop'] = $_GET['desktop'];
33+
}
34+
35+
// Check if url is requesting mobile, and enabled in templateDetails.xml
36+
if (isset($_GET['mobile']) && $allowMobileUrl) {
37+
$_SESSION['mobile'] = $_GET['mobile'];
38+
// unset view desktop session
39+
if (isset($_SESSION['desktop'])) {
40+
unset($_SESSION['desktop']);
41+
}
3342
}
3443

3544
// Check if mobile device detection is turned on and, test if visitor is a mobile device, and if so, load mobile sub-template
36-
if ((($mdetect && $isMobile) || ($mdetect && $detectTablets && $isTablet)) && (!isset($_SESSION['viewDesktop']))) {
45+
if ((($mdetect && $isMobile) || ($mdetect && $detectTablets && $isTablet) || (isset($_SESSION['mobile']) && $allowMobileUrl)) && (!isset($_SESSION['desktop']))) {
3746
if (JFile::exists($mTemplate)) {
3847
include_once $mTemplate;
3948
}

language/en-GB/en-GB.tpl_construct.ini

+2
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,8 @@ padding-bottom:0;
5858
<p>Allowing even greater flexibility of your design is the ability to add article, menu item, category, section and component specific extended template overrides. Place these appropriately named files in the right folder and the template will load them automatically. For example, to create an extended template override for article 37, add your new layout named <code>article-37.php</code> to <em>/layouts/article</em> and CSS named <code>article-37.css</code> to <em>/css/article</em>.</p>
5959
<p>Joomla! Template Development Framework &copy; 2009 - 2012 Matt Thomas</p>
6060
<p>For more information and support, visit <a href="_QQ_"http://construct-framework.com/"_QQ_" target="_QQ_"_blank"_QQ_">Construct Framework</a></p>"
61+
TPL_CONSTRUCT5_ALLOW_MOBILE_URL_LABEL="Allow Mobile URL"
62+
TPL_CONSTRUCT5_ALLOW_MOBILE_URL_DESC="Allow mobile view to load with url query site.com/index.php?mobile"
6163
TPL_CONSTRUCT_DETECT_TABLETS_DESC="Include tablet devices in the mobile detection and load the mobile version of the temeplate."
6264
TPL_CONSTRUCT_DETECT_TABLETS_LABEL="Include Tablet Devices"
6365
TPL_CONSTRUCT_ENABLE_SWITCHER_DESC="Enable the ajax style sheet switcher. Defaults to diagnostic and normal options for a visual layout aid."

layouts/mobile-offline.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@
8484
<?php endif ?>
8585

8686
<div id="footer" data-role="footer" data-theme="<?php echo $mFooterDataTheme ?>">
87-
<a class="view-desktop" href="<?php echo JURI::current() ?>?viewDesktop=true">View Desktop Version</a>
87+
<a class="view-desktop" href="<?php echo JURI::current() ?>?desktop">View Desktop Version</a>
8888
<?php if ($this->countModules('footer')) : ?>
8989
<jdoc:include type="modules" name="footer" style="xhtml" />
9090
<?php endif ?>

layouts/mobile.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@
9595
<?php endif ?>
9696

9797
<div id="footer" data-role="footer" data-theme="<?php echo $mFooterDataTheme ?>">
98-
<a class="view-desktop" href="<?php echo JURI::current() ?>?viewDesktop=true">View Desktop Version</a>
98+
<a class="view-desktop" href="<?php echo JURI::current() ?>?desktop">View Desktop Version</a>
9999
<?php if ($this->countModules('footer')) : ?>
100100
<jdoc:include type="modules" name="footer" style="xhtml" />
101101
<?php endif ?>

mobile-offline.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@
9393
<?php endif ?>
9494

9595
<div id="footer" data-role="footer" data-theme="<?php echo $mFooterDataTheme ?>">
96-
<a class="view-desktop" href="<?php echo JURI::current() ?>?viewDesktop=true">View Desktop Version</a>
96+
<a class="view-desktop" href="<?php echo JURI::current() ?>?desktop">View Desktop Version</a>
9797
<?php if ($this->countModules('footer')) : ?>
9898
<jdoc:include type="modules" name="footer" style="xhtml" />
9999
<?php endif ?>

mobile.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@
102102
<?php endif ?>
103103

104104
<div id="footer" data-role="footer" data-theme="<?php echo $mFooterDataTheme ?>">
105-
<a class="view-desktop" href="<?php echo JURI::current() ?>?viewDesktop=true">View Desktop Version</a>
105+
<a class="view-desktop" href="<?php echo JURI::current() ?>?desktop">View Desktop Version</a>
106106
<?php if ($this->countModules('footer')) : ?>
107107
<jdoc:include type="modules" name="footer" style="xhtml" />
108108
<?php endif ?>

templateDetails.xml

+12-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<!DOCTYPE install PUBLIC "-//Joomla! 1.6//DTD template 1.0//EN" "http://www.joomla.org/xml/dtd/1.6/template-install.dtd">
3-
<extension version="1.6" type="template" client="site" method="upgrade">
3+
<extension version="1.6"
4+
type="template"
5+
client="site"
6+
method="upgrade">
47
<name>construct</name>
58
<creationDate>December 11, 2012</creationDate>
69
<author>Matt Thomas</author>
@@ -315,6 +318,14 @@
315318
<option value="1">Yes</option>
316319
<option value="0">No</option>
317320
</field>
321+
<field name="allowMobileUrl"
322+
type="radio"
323+
default="1"
324+
label="TPL_CONSTRUCT_ALLOW_MOBILE_URL_LABEL"
325+
description="TPL_CONSTRUCT_ALLOW_MOBILE_URL_DESC">
326+
<option value="1">Yes</option>
327+
<option value="0">No</option>
328+
</field>
318329
<field name="mNavPosition"
319330
type="radio"
320331
default="0"

0 commit comments

Comments
 (0)