Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
I18N OnePage
#1
I have created the I18N OnePage plugin to simplify the creation of single page themes.

With version 0.9 the API has changed to simplify usage:
  • At the beginning of the template (before get_header() or similar) specify which pages to display on this page: pass the parent slug of the pages to add (only available if you use the I18N plugin) or nothing (for all pages in the menu) to the set_onepage_content function - this will take care that plugins can access the full content already in the header, as e.g. the I18N Gallery plugin does:
PHP Code:
<?php set_onepage_content('my-parent-slug'); ?>
  • add the navigation:
PHP Code:
<?php get_onepage_navigation(); ?>
  • wrap get_page_title()/get_page_content() in a loop like that:
PHP Code:
<?php while (next_onepage_content()) { ?>
  <h2><?php get_onepage_anchor(); ?><?php get_page_title(); ?></h2>
  <?php get_page_content(); ?>
<?php 
?>

For more options consult the header of the plugin file.

If you use the I18N plugin, you can mix normal pages and pages combining multiple pages:
  • create a template like described above and use set_onepage_content(return_page_slug())
  • create an empty page "my-multipage" and assign it this template
  • create other pages as children of this page and add them to the menu.
If you display "my-multipage", the content of all its children will be displayed on the page.

The plugin support I18N, I18N Custom Fields and I18N Special Pages (exception: the code to add custom header content for the special page will not be processed).
I18N, I18N Search, I18N Gallery, I18N Special Pages - essential plugins for multi-language sites.
Reply
#2
(2015-11-28, 08:55:55)mvlcek Wrote: I have created the I18N OnePage plugin to simplify the creation of single page themes.  ...

Hi  mvlcek

I have quickly checked out your OnePage plugin v02.

Everything looks good, EXCEPT you have a typo in Onepage thread post  … which causes a TOTALLY BLANK html page ..  Reason : In  the forum OnePage plugin thread post for the while  loop code to set the OnePage content with slugs in menu order you call return_i18n_structure() … but  it looks like  return_i18n_structure()  DOES NOT EXIST. Instead return_i18n_page_structure() exists … do you mean this ?

I also noticed you have the same typo in i18n_navigation.php (v329) (the probable reason for above typo)  : In the public functions comment header you have “return_i18n_structure()”  but in the code in the same file there is no such function. Instead there is “return_i18n_page_structure()”    … I assume you mean this


a.  So using return_i18n_page_structure() instead of return_i18n_structure()  I used the following template code  … and all  works well  :

PHP Code:
<head>
 
 ......
 
 <! Setup OnePage content here --> 
 
 <?php 
      $slugs 
= array();
 
     $pages return_i18n_page_structure();  // Was return_i18n_structure() but does not exist
 
     foreach ($pages as $page) {
 
       $slugs[] = $page['url'];
 
     }
 
     set_onepage_content(false$slugs);
 
 ?>

  <!-- Insert meta tags Keywords, Description -->
  <!--  or <?php // get_header(); ?> -->
  <?php get_i18n_header(); ?>  

</head>

<body>
   .....   
   <div id="page-content">

      <!--  Insert OnePage content here -->
      <?php while (has_onepage_content()) { ?>
      
           <a name="<?php echo(return_onepage_slug()); ?>"></a>
           <h2><?php getPageField(return_onepage_slug(), "title"); ?></h2>
           <?php get_onepage_content(); ?>
           
      <?php ?>       

   </div>
   .....      
</body> 

b.    All   works well   …
i.    set_onepage_content(false, $slugs) works well   … with a manual list of slugs works well
ii.    Frontend language switching all works well  (I  currently have English and German )
iii.    The get_onepage_content() while (has_onepage_content()) works well, and the filter replace of the  (% gallery  %)  tags  (and the filtering for other plugins I have) is  good, and also the language switching of gallery captions is working   


c.    Suggestions   -  I know the following is not part of your plugin but it could be useful info … so that everything is in one place    

i.    I think the default Use Case for the Onepage plugin will be to  a) display all Backend (menu displayed) pages in one, and b)  have a menu with anchor hrefs  which link to each page part in the OnePage page    ..  Do you think so ?     

ii.    So if so, how about show this in the forum plugin post   ..  a) include an <a> tag line in the display while loop that you already have :

  <a name="<?php echo(return_onepage_slug()); ?>"></a>   

iii.    Explain about setting in the Backend the Custom Permalink Structure textfield to  #%slug%   …

iv.    Don’t include in the menu / OnePage the index page because the url for the index page would be <root>  and not  <root>/#index    (unless that could be changed ?)

v.    Also what’s the situation with template file choice in the Backend for each page ?  For a normal multipage solution, you can choose a different template file for each page, but obviously for a OnePage solution it makes no sense to define different template files  . .. I guess if you do, something must get ignored  .. I have not experimented  .. I have only used one file - the default template.php.  So for a OnePpage solution  what is the exact instruction  for how to define the template file in the Backend ?

Cheers Aldebaran
 
Reply
#3
(2015-11-30, 21:30:00)aldebaran Wrote: c.    Suggestions   -  I know the following is not part of your plugin but it could be useful info … so that everything is in one place    

The new version of the plugin simplifies usage and incorporates your suggestions:
  1. the function set_onepage_content() takes the parent slug or nothing for all pages
  2. the function get_onepage_navigation() outputs a navigation menu
  3. the function get_onepage_anchor() outputs an anchor
(2015-11-30, 21:30:00)aldebaran Wrote: iii.    Explain about setting in the Backend the Custom Permalink Structure textfield to  #%slug%   …
  • the permalink structure in the backend does not need to be changed
(2015-11-30, 21:30:00)aldebaran Wrote: v.    Also what’s the situation with template file choice in the Backend for each page ?

There must be one page - the page being visited by the user - that must have the correct template file - that with the onepage functions - set. The template file for the included pages is ignored.
I18N, I18N Search, I18N Gallery, I18N Special Pages - essential plugins for multi-language sites.
Reply
#4
I imagine you could do all this automatically using filters
NEW: SA Admin Toolbar Plugin | View All My Plugins
- Shawn A aka Tablatronix
Reply
#5
(2015-12-02, 09:13:25)shawn_a Wrote: I imagine you could do all this automatically using filters

I don't think so:
  • for the header processing all content of all pages is concatenated into the content (e.g. needed for I18N Gallery)
  • then for each next_onepage_content() the globals $content, $data_index, etc. are exchanged to ensure proper processing
  • get_onepage_navigation: theoretically you could use filter "menuitems" and replace all the HTML - quite inefficient
I18N, I18N Search, I18N Gallery, I18N Special Pages - essential plugins for multi-language sites.
Reply
#6
Hi mvlek

v09 works fine for me ..   I have only tried the  'all pages' option for set_onepage_content()

Thanks for this plugin  !

Cheers Aldebaran  
Reply
#7
Oh yeah makes sense, forgot about the globals nonsense
It could be done quick and dirty and compatible with all themes but would probably have content filter issues to resolve
NEW: SA Admin Toolbar Plugin | View All My Plugins
- Shawn A aka Tablatronix
Reply
#8
Hi Mvlcek

I have request  - in the case of using a mixture of single and multipage pages, when you navigate back from a single page to a multipage – is it possible to  include an anchor ref  to the subpage within the multipage ?   

Below is what I  want to do and what I have done so far   ... So what do think  ?     Have I misunderstood something ?  Can I do what I want some other way  ?  Or do I need an extra anchor ref  in the navi from a single page to a multipage ?  


This is what I am trying to do for a website :
 
i.    I have one multipage and a few single pages. The index url navigate to the multipage. On all the multi and single pages the menu just has item refs to each subpage of the multipage. The single pages contain stuff which is not of immediate importance to the user / are not part of the “main message” and so are not in the menu, but their access is just via links eg  in the footer. At the moment I have just one single page containing legal stuff.     

ii.    From the users perspective, I want the menu in each of the frontend multipage and the single pages to look the same and do the same, ie it is a simple flat menu which just contains menu items to navigate to each sub page within the multipage.

iii.    So to go to a multipage subpage from a menu item then there must be an anchor ref as part of the href. For navigating from within the multipage then just the anchor ref  is enough, but  - as far as I see it  -  for navigating from a single page, we need the site url, an id url param to nav to the  multipage (if required), and then an anchor ref to the subpage  


And this is what have done so far …

i.    In the single page template file I have for the menu navigation  :

 <?php  get_i18n_navigation('index',1,1); ?>  

..  So this creates menu items such as href = ”http://my.website.com/index.php?id=sub-page-1”


ii.    In the backend ALL child pages, as well as the parent index page, are associated with the  multipage template    … so that on clicking a menu item from a single page then (with url ..?id=my-sub-page”) we  load up the  multipage template

iii.    In the  multipage template file  for the content setup  I have

set_onepage_content(‘index’)     

… and NOT set_onepage_content(return_page_slug() so that this does not load up the single page defined by the id url param, but instead loads up the index child pages for the multipage

iv.    But here is my PROBLEM      … with the above url  in the single page I navigate to the multipage, but the scroll stays at the top and does not go to the subpage within he multipage  .. to  do that  I need an extra anchor ref   #my-sub-page
 


Cheers Aldebaran
Reply
#9
Re my post above about a request  to work with  single pages   ...

It’s OK,  I have done my own simple solution  …  it involves adding an extra function in the onepage plugin  file  … and is just a temporary workaround solution for me. 

What I have done is   :

a.    Don’t define any child pages, just have all parent pages and assoc the pages you want with the menu to group together as a multipage. Call all other  non menu pages ‘single pages’    

b.    Define a template for the multipage, and a template for a single page which is not part of the menu

c.    For the multipage template, define as mvlek. Add links on the multipage template to  single pages using the normal id url param

d.    For a  single page template   ..

  i.    In the header   define set_onepage_content  …   this is only to fetch all the slugs of the multipage so can do the menu

  ii.    For the menu  for a single page I have added to the onepage plugin file  a moded version of the get_onepage_navigation() function – call this get_onepage_navigation_multoone(), where instead of just href = ‘#<slug>’, I have  href = ‘get_site_url(false)#<slug>’ (just pseudocode),  for each slug in the onepage menu list
 
  iii.    For the menu call get_onepage_navigation_multoone()

  iv.    For the content, call get_i18n_content(return_page_slug()) instead of the normal  get_page_content(), This is because get_page_content() just returns $content, but  $content has been replace with the onepage  content,   but here we want the content  defined by the slug sent with the url param  ‘id’

e.    So with this single page menu we navigate to the multipage AND  to a specific page within the multipage


  ... if anyone is interested  I can post the exact code details   ..
Reply
#10
(2015-12-30, 22:33:47)aldebaran Wrote: Re my post above about a request  to work with  single pages   ...

It’s OK,  I have done my own simple solution  …  it involves adding an extra function in the onepage plugin  file  … and is just a temporary workaround solution for me. 

What I have done is   :

a.    Don’t define any child pages, just have all parent pages and assoc the pages you want with the menu to group together as a multipage. Call all other  non menu pages ‘single pages’    

b.    Define a template for the multipage, and a template for a single page which is not part of the menu

c.    For the multipage template, define as mvlek. Add links on the multipage template to  single pages using the normal id url param

d.    For a  single page template   ..

  i.    In the header   define set_onepage_content  …   this is only to fetch all the slugs of the multipage so can do the menu

  ii.    For the menu  for a single page I have added to the onepage plugin file  a moded version of the get_onepage_navigation() function – call this get_onepage_navigation_multoone(), where instead of just href = ‘#<slug>’, I have  href = ‘get_site_url(false)#<slug>’ (just pseudocode),  for each slug in the onepage menu list
 
  iii.    For the menu call get_onepage_navigation_multoone()

  iv.    For the content, call get_i18n_content(return_page_slug()) instead of the normal  get_page_content(), This is because get_page_content() just returns $content, but  $content has been replace with the onepage  content,   but here we want the content  defined by the slug sent with the url param  ‘id’

e.    So with this single page menu we navigate to the multipage AND  to a specific page within the multipage


  ... if anyone is interested  I can post the exact code details   ..

Hi,
yes, I’m interesting... 
Nice day from Slovenia,
Darko
Reply
#11
Quote:The plugin support I18N, I18N Custom Fields and I18N Special Pages (exception: the code to add custom header content for the special page will not be processed).

Hi Thanks for the OnePage plugin! But I don't get it using the custom fields plugin. When I loop through the pages and try to output custom-field-contents from subpages, it does not give the stored value back. The custom-fields var is and stays filled by the mother-page custom-field content. Is there a chance to get the contents of the actual outputted subpage custom field? 

I think I'm doing something wrong. But what?!

Code:
    <?php while (next_onepage_content()) { ?>
        <section class="wrapper <?php get_custom_field('SectionStyle'); ?>">
             <div class="row">
              <h2><?php get_onepage_anchor(); ?><?php get_page_title(); ?></h2>
             </div>
             <div class="row">
              <?php get_page_content(); ?>
             </div>
        </section>
    <?php } ?>

The custom-field "SectionStyle" should get a string from the current printed "onepage-subpage". I just want to add an individual style to the section. 

Any hints? Please  Shy

---
Addition: Aehm, sorry  Big Grin  The custom fields have to be lower-case. Mine was a mixture "SectionStyle" - after changing the source to lower case, everything runs fine now.  Rolleyes
Reply
#12
(2015-11-28, 08:55:55)mvlcek Wrote: If you use the I18N plugin, you can mix normal pages and pages combining multiple pages:
  • create a template like described above and use set_onepage_content(return_page_slug())
  • create an empty page "my-multipage" and assign it this template
  • create other pages as children of this page and add them to the menu.
If you display "my-multipage", the content of all its children will be displayed on the page.

Hello,
i want to create a onepager with multiple pages and one or two additional normal pages (credits, legal stuff).
So I installed I18n, I18base, and this I18N onepage plug in. After editing my template as described everything worked fine for the multipages.
Then I altered the code to set_onepage_content(return_page_slug()), created the empty page (even called it my-multipage at first, then changed to index) with subpages + one extra page.
Again, the multipages work, but the normal page is not showing up in the menu!?
What am I doing wrong?
I played arround a little and assigned a template with set_onepage_content() to the single page - didn`t help.
Then I recognized, if I add a second i18n menu call after the onepage menu call, I get the menu link of the extra page, but the page is empty - I guess because of the onepage content before get_header?
The same happens, when hardcoding this single menu link.
The only way to get the menu link AND the content was to set up a second empty parent page with the single normal page as a child.
But then I still have a problem: on the multipages all the menu links are showing up (this child pages, the second parent, showing its child and the hardcoded link as well), but on all this other pages the onepage menu is missing. (Even on the second parent and child page - the only difference here is, the 1st parent is the index slug)

I relly can´t see the solution, and as there´s not even showing up the content of the normal page with all the considered settings I didn`t try to follow aldebarans challenging suggestions.

I hope somebody can help me!?
Reply




Users browsing this thread: 1 Guest(s)