zenphoto forums » General Zenphoto Discussion

Setting Zenpage Homepage on zpMobile

(4 posts)
  • Started 10 months ago by risottto
  • Latest reply from acrylian
  1. risottto

    Member
    Joined: Jun '12
    Posts: 24

    I have my website functioning perfectly using a modified zenpage theme for desktop browsers, now I am just trying to get it to work on mobile devices using the zpMobile theme.

    I have almost everything done except for one issue I can't quite figure out:

    on the desktop theme, I have a unpublished page called "home" which is the splash page I have set as the Homepage under Custom Theme Options under Zenpage. I am trying to duplicate the same behavior in zpMobile.

    I tried using the code from the zenpage index.php in zpmobile:

    <?php
    
    // force UTF-8 Ø
    
    if(function_exists("checkForPage")) { // check if Zenpage is enabled or not
    	if (checkForPage(getOption("zenpage_homepage"))) { // switch to a news page
    		$ishomepage = true;
    		include ('pages.php');
    	} else {
    		include ('gallery.php');
    	}
    } else {
    	include ('gallery.php');
    }
    ?>

    But this leads to the gallery page being used as home. The zenpage plugin is active, is the 'zenpage_homepage' option still active when the zmMobile theme is active? or can I fake this behavior somehow?

    Thanks for the great work, I am slowly getting a handle on theming with jQuery mobile, but that's a whole other story.

    Posted 10 months ago #
  2. Zenphoto development team
    acrylian

    Developer
    Joined: Jul '07
    Posts: 13,341

    I have not setup the theme for that at all but actually that code should work. Besides that jquerymobile is a bit special regarding html5 setup it is just a theme. But sometimes its own js cache causes issue (for example it is not possible to link to anchors within the same page).

    Did you clear the browser and if used the html cache of ZP (although the latter is not active if your are logged in).

    You could also manually modify the index.php to use the page in question using the object model.

    You also could open a ticket for this homepage feature for 1.4.4.

    Don't forget to read the Forum rules and usage resources
    Posted 10 months ago #
  3. risottto

    Member
    Joined: Jun '12
    Posts: 24

    Figured it out: went into zpMobile themeoptions.php and added:

    setThemeOptionDefault('zenpage_homepage', 'none');

    to the function Themeoptions and

    gettext('Homepage') => array('key' => 'zenpage_homepage', 'type' => OPTION_TYPE_CUSTOM, 'desc' => gettext("Choose here any <em>un-published Zenpage page</em> (listed by <em>titlelink</em>) to act as your site's homepage instead the normal gallery index.")."<p class='notebox'>".gettext("<strong>Note:</strong> This of course overrides the <em>News on index page</em> option and your theme must be setup for this feature! Visit the theming tutorial for details.")."</p>"),

    to the getoptionssupported function

    then threw in

    if($option == "zenpage_homepage") {
    			$unpublishedpages = query_full_array("SELECT titlelink FROM ".prefix('pages')." WHERE <code>show</code> != 1 ORDER by <code>sort_order</code>");
    			if(empty($unpublishedpages)) {
    				echo gettext("No unpublished pages available");
    				// clear option if no unpublished pages are available or have been published meanwhile
    				// so that the normal gallery index appears and no page is accidentally set if set to unpublished again.
    				setOption("zenpage_homepage", "none", false);
    			} else {
    				echo '<input type="hidden" name="'.CUSTOM_OPTION_PREFIX.'selector-zenpage_homepage" value="0" />' . "\n";
    				echo '<select id="'.$option.'" name="zenpage_homepage">'."\n";
    				if($currentValue === "none") {
    					$selected = " selected = 'selected'";
    				} else {
    					$selected = "";
    				}
    				echo "<option$selected>".gettext("none")."</option>";
    				foreach($unpublishedpages as $page) {
    					if($currentValue === $page["titlelink"]) {
    						$selected = " selected = 'selected'";
    					} else {
    						$selected = "";
    					}
    					echo "<option$selected>".$page["titlelink"]."</option>";
    				}
    				echo "</select>\n";
    			}
    		}

    into function handleOption

    All that did not work exactly, it printed a list of my pages on the splash page... until I figured out that I had to get rid of this code from pages.php

    <?php if(empty($_GET['title'])) { ?>
    
    			<h2><?php echo gettext('Pages'); ?></h2>
    			<br />
    			<ul data-role="listview" data-inset="true" data-theme="c" data-dividertheme="b">
    			<?php printPageMenu("list-top","","menu-active","submenu","menu-active",NULL,true,false,NULL); ?>
    			</ul>
    	<?php	} else { ?>

    now it works like a charm. I also bogarted the custom menu plugin and made a mobile version that lists my pages in the menu.

    I figure someone could use this in the future. It was all theme tweaking, basically stealing from zenpage.

    Posted 10 months ago #
  4. Zenphoto development team
    acrylian

    Developer
    Joined: Jul '07
    Posts: 13,341

    This is how thtemes are meant, to be modified if needed. If you like to see this an official feature please open a ticket. Otherwise it most likely gets forgotten.

    Don't forget to read the Forum rules and usage resources
    Posted 10 months ago #

RSS feed for this topic

Reply

You must log in to post.