- Posts: 29
COMMUNITY FORUM
Uber Page Break does not create sef urls
- Adamo
-
Topic Author
- Offline
- Junior Member
i've just find an error in UberPageBreak plugin that omitted of insert the limit parameter in the generated urls, so sh404sef creates wrong urls.
I've fix the problem by adding the limit parameter at lines 164, 189, 210. The strange thing is that when the plugin creates the url for prev and next buttons and for the "One page" visualitation, it adds the parameter and urls work correctly. This should be an oversight.
But there is more. The urls generated by the plugin are the type of "Page-x.html". So i've edit also the sh404sef code to permit the correct handling of the pagination in K2. I contacted the sh404sef's developers and they tell me taht they should be very happy to insert my editing in their code. So i contacted also JoomlaWorks (by the contact form on their site) to explain them what i done but they don't reply me. So i'ìm writing here, hoping someone can read this post and fix the UberPagePlugin issues.
If you like to have more axplanation i'm here :)
Adamo "Aerendir" Crespi
Please Log in or Create an account to join the conversation.
- AdrianK
-
- Offline
- Senior Member
- Posts: 46
I think its a serious bug of the sh404sef router, because every page as limitstart,
cause Page-1.
Please Log in or Create an account to join the conversation.
- Adamo
-
Topic Author
- Offline
- Junior Member
- Posts: 29
Hello,
I think its a serious bug of the sh404sef router, because every page as limitstart,
cause Page-1.
Hi Titus, no it is not an sh404sef bug but an oversight in uberpagebreak: you have to add the limit parameter at lines
162, 187, 208. The result is this
@Willem Here is the solution.
161 // TOC page link
162 $output->links[$key]->pagelink = JRoute::_('&limit=1&showall=&limitstart='.($i-1));
186 // TOC footer link
187 $output->footerLink = JRoute::_('&limit=1&showall=1&limitstart=');
208 $output->navNextLink = JRoute::_('&limit&limitstart='.$page_next);
Final notes
These edits solve only the pagination issue. The resulting url is ever in the form page-x.html because it is handled by the sh404sef general engine.
If you want to use the aliases or the titles of your articles to create the urls it is necessary to integrate uberPageBreak with SH404Sef. Yannik (Sh404SEF) knows the problem. It is necessary the small update in the plugin UberPageBreak by JoomlaWorks so also sh404sef will be updated and the integration will be in production releases.
But at that time anyone from JoomlaWorks reply me here in the forum or by email (i sent them an email from their site explicating the problem and the solution).
We are waiting for them :(
Please Log in or Create an account to join the conversation.
- Brenda
-
- Offline
- New Member
- Posts: 13
Please Log in or Create an account to join the conversation.
- Adamo
-
Topic Author
- Offline
- Junior Member
- Posts: 29
Please Log in or Create an account to join the conversation.
- Brenda
-
- Offline
- New Member
- Posts: 13
Thanks for posting this!! I was having problems with using UberPageBreak with SH404SEF. I'm using the Tabs template. I have three tabs and the 3rd tab didn't work until I first click on Page 3 at the bottom of my article. These changes work perfectly!!
Please Log in or Create an account to join the conversation.
- Adamo
-
Topic Author
- Offline
- Junior Member
- Posts: 29
i can't write the changes i made because now there are new versions of sh404sef and i don't know if there are well for the actual version.
Anyway, in the file administrator/components/com_sh404sef/sh404sef.class.php i duplicated the virtuemart section and adapt it for k2. In this way i also obtain the url builded by alias and not by the general string "page-x".
If not remember wrong (i didn't made this change at this time and for a lot of time) the problem you have is caused because k2 and uberpagebrak aren't integrated with sh404sef.
To solve definitely the problem it is necessary that sh404sef team and the k2/uberPageBreak one work together to solve the problem. At this time i sent an email to JoomlaWorks but no one replied me and we have the problem yet.
If some one other send them an email maybe possibile the teams solve the problem.
Please Log in or Create an account to join the conversation.
- Brenda
-
- Offline
- New Member
- Posts: 13
I changed this file:
/plugins/content/UberPageBreak.php
and changed these lines:
161 // TOC page link
162 $output->links[$key]->pagelink = JRoute::_('&limit=1&showall=&limitstart='.($i-1));
186 // TOC footer link
187 $output->footerLink = JRoute::_('&limit=1&showall=1&limitstart=');
208 $output->navNextLink = JRoute::_('&limit&limitstart='.$page_next);
The whole file looks like this:
<?php /*// JoomlaWorks "UberPageBreak" Plugin for Joomla! 1.5.x - Version 1.0// Copyright (c) 2006 - 2010 JoomlaWorks, a business unit of Nuevvo Webware Ltd. All rights reserved.// Released under the GNU/GPL license: www.gnu.org/copyleft/gpl.html// More info at www.joomlaworks.gr// Designed and developed by the JoomlaWorks team// ***Last update: June 25th, 2010****/// no direct accessdefined('_JEXEC') or die('Restricted access');jimport( 'joomla.plugin.plugin' );class plgContentUberPageBreak extends JPlugin { // JoomlaWorks reference parameters var $plg_name = "UberPageBreak"; var $plg_copyrights_start = "\n\n<!-- JoomlaWorks \"UberPageBreak\" Plugin (v1.0) starts here -->\n"; var $plg_copyrights_end = "\n<!-- JoomlaWorks \"UberPageBreak\" Plugin (v1.0) ends here -->\n\n"; function plgContentUberPageBreak( &$subject, $params ){ parent::__construct( $subject, $params ); } function onPrepareContent( &$row, &$params, $page=0 ){ // API $mainframe = &JFactory::getApplication(); $document = &JFactory::getDocument(); $db = &JFactory::getDBO(); // Requests $option = JRequest::getCmd('option'); $view = JRequest::getCmd('view'); $layout = JRequest::getCmd('layout'); $itemid = JRequest::getInt('Itemid'); $print = JRequest::getBool('print'); $limitstart = JRequest::getInt('limitstart',0); $showall = JRequest::getInt('showall',0); if(!$page) $page = 0; // Assign paths $sitePath = JPATH_SITE; $siteUrl = substr(JURI::root(), 0, -1); // Check if plugin is enabled if(JPluginHelper::isEnabled('content',$this->plg_name)==false) return; // Load the plugin language file the proper way JPlugin::loadLanguage('plg_content_'.$this->plg_name, JPATH_ADMINISTRATOR); // Simple performance checks to determine whether plugin should process further if(strpos($row->text,'class="system-pagebreak')===false && strpos($row->text,'class=\'system-pagebreak')===false){ return true; } // Expression to search for $regex = '#<hr([^>]*?)class=(\"|\')system-pagebreak(\"|\')([^>]*?)\/*>#iU'; if($params->get('intro_only') || $params->get('popup') || ($view!= 'article' && $view!='item')){ $row->text = preg_replace($regex,'',$row->text); return; } // For K2 if($option=='com_k2'){ if(!empty($row->fulltext)){ $row->text = $row->fulltext; } else { $row->text = $row->introtext; } } // Clear pagebreak tags on print page if(JRequest::getInt('print')){ $row->text = preg_replace($regex,'<br />',$row->text); return; } //
Get plugin parameters
// Get Plugin info $plugin =& JPluginHelper::getPlugin('content',$this->plg_name); $pluginParams = new JParameter( $plugin->params ); $pluginTemplate = $pluginParams->get('pluginTemplate','Default'); // to add to XML: Default or Tabs incl. on-the-fly MVC $ubpPageTitle = $pluginParams->get('ubpPageTitle',1); $ubpTOC = $pluginParams->get('ubpTOC',1); $ubpNavigation = $pluginParams->get('ubpNavigation',1); $ubpAllPagesLink= $pluginParams->get('ubpAllPagesLink',1); $ubpPageCounter = $pluginParams->get('ubpPageCounter',1); // Includes require_once(dirname(__FILE__).DS.$this->plg_name.DS.'includes'.DS.'helper.php'); //
Head includes
$pluginCSS = UberPageBreakHelper::getTemplatePath($this->plg_name,'css/template.css',$pluginTemplate); $pluginCSS = $pluginCSS->http; $headIncludes = '<style type="text/css" media="all"> @import "'.$pluginCSS.'";</style> '; //
Prepare the output
// Find all instances of plugin and put in $matches $matches = array(); preg_match_all($regex, $row->text, $matches, PREG_SET_ORDER); // Split the text around the plugin $text = preg_split($regex, $row->text); // Count the number of pages $n = count($text); // We have found at least one plugin instance, therefore at least 2 pages if($n > 1){ $output = new JObject; // TOC header title $output->headerTitle = $row->title; // Set the page title if($ubpPageTitle && $page){ $page_text = $page + 1; if($page && @$matches[$page-1][2]){ $attrs = JUtility::parseAttributes($matches[$page-1][0]); if(@$attrs){ $row->title = $row->title.' - '.$attrs; } else { $thispage = $page + 1; $row->title = $row->title.' - '.JText::_( 'Page' ).' '.$thispage; } } } // TOC header link $output->headerLink = JRoute::_('&showall=&limitstart='); // TOC header active class $output->headerActiveClass = ($limitstart === 0 && $showall === 0) ? true : false; $i = 2; foreach($matches as $key=>$match){ $key = $key + 1; $output->links[$key] = new JObject; // TOC page link $output->links[$key]->pagelink = JRoute::_('&limit=1&showall=&limitstart='.($i-1)); // TOC page title if(@$match[0]){ $attrs2 = JUtility::parseAttributes($match[0]); if(@$attrs2){ $title = stripslashes($attrs2); } elseif(@$attrs2) { $title = stripslashes($attrs2); } else { $title = JText::sprintf('Page #',$i); } } else { $title = JText::sprintf('Page #',$i); } $output->links[$key]->title = $title; // TOC page active & odd/even classes $output->links[$key]->linkActiveClass = ($limitstart == $i-1) ? true : false; $output->links[$key]->linkOddOrEvenClass = ($key%2) ? 'odd' : 'even'; $i++; } // TOC footer link $output->footerLink = JRoute::_('&limit=1&showall=1&limitstart='); // TOC footer active class $output->footerActiveClass = ($showall == 1) ? true : false; // Article text - we clean it up from the plugin tags on each created page $output->text[$page] = str_replace("<hr id=\"\"system-readmore\"\" />", "", $text[$page]); // Page navigation jimport('joomla.html.pagination'); $pageNavigation = new JPagination($n, $page, 1); // Page counter $output->pageCounter = $pageNavigation->getPagesCounter(); // Page navigation links $output->navPageLinks = $pageNavigation->getPagesLinks(); // Prev/Next navigation links if($page<$n-1 && !$showall){ $page_next = $page + 1; $output->navNextLink = JRoute::_('&limit&limitstart='.$page_next); $output->navNextText = JText::_('Next').' '.JText::_('&gt;&gt;'); } else { $output->navNextLink = ''; $output->navNextText = JText::_('Next'); } if($page>0 && !$showall){ $page_prev = ($page - 1 == 0) ? "" : $page - 1; $output->navPrevLink = JRoute::_('&limitstart='.$page_prev); $output->navPrevText = JText::_('&lt;&lt;').' '.JText::_('Prev'); } else { $output->navPrevLink = ''; $output->navPrevText = JText::_('Prev'); } //
Render the output
// Load the head includes //UberPageBreakHelper::loadHeadIncludes($this->plg_copyrights_start.$headIncludes.$this->plg_copyrights_end); //$document->addCustomTag($this->plg_copyrights_start.$headIncludes.$this->plg_copyrights_end); $document->addStyleSheet($pluginCSS); // Set the "all pages" output if($showall && $ubpAllPagesLink){ $page = 1; $output->pageText = preg_replace($regex,'<br />', $row->text); } else { $output->pageText = $output->text[$page]; } // Fetch the template ob_start(); $getTemplatePath = UberPageBreakHelper::getTemplatePath($this->plg_name,'default.php',$pluginTemplate); $getTemplatePath = $getTemplatePath->file; include($getTemplatePath); $getTemplate = $this->plg_copyrights_start.ob_get_contents().$this->plg_copyrights_end; ob_end_clean(); // Do the replace if($option=='com_k2'){ if(!empty($row->fulltext)){ $row->text = $row->introtext.'{K2Splitter}'.$getTemplate; } else { $row->text = $getTemplate; } } else { $row->text = $getTemplate; } } }} // End class/*** LEGEND: Page break plugin** <b>Usage:</b>* <code><hr class="system-pagebreak" /></code>* <code><hr class="system-pagebreak" title="The page title" /></code>* or* <code><hr class="system-pagebreak" alt="The first page" /></code>* or* <code><hr class="system-pagebreak" title="The page title" alt="The first page" /></code>* or* <code><hr class="system-pagebreak" alt="The first page" title="The page title" /></code>**/
Please Log in or Create an account to join the conversation.
- Brenda
-
- Offline
- New Member
- Posts: 13
Please Log in or Create an account to join the conversation.
- AdrianK
-
- Offline
- Senior Member
- Posts: 46
can you please support a download-link?
I have trouble with the native joomla seo and urls of K2. With artio joomlsef 3
and a k2-plugin uberpagebreak generates correct urls, I think its possibly a
problem with the native sef of joomla and the page-property, limitstart is
not absolute.
Best regards,
Titus
Please Log in or Create an account to join the conversation.
- AdrianK
-
- Offline
- Senior Member
- Posts: 46
Please Log in or Create an account to join the conversation.
- Adamo
-
Topic Author
- Offline
- Junior Member
- Posts: 29
Please Log in or Create an account to join the conversation.
- 3cantos.org
-
- Offline
- New Member
- Posts: 1
Arround line 1836 in sh404sef.class.php you´ll see "// V 1.2.4.t special processing to replace page number by headings..."
Here, we need to check if option is com_k2 and, if so, we need to change the query.
1.- Change
if ( strpos($url, 'option=com_content') !== false && strpos($url, 'view=article') !== false && !empty($limitstart) )
New code:
if (( strpos($url, 'option=com_content') !== false && strpos($url, 'view=article') !== false && !empty($limitstart) ) || ( strpos($url, 'option=com_k2') !== false && strpos($url, 'view=item') !== false && !empty($limitstart) ))
2.- Change this line
$sql = 'SELECT c.id, c.fulltext, c.introtext FROM #__content AS c WHERE id=\''.$shParams.'\'';
new code:
if (strpos($url, 'option=com_k2')) $sql='SELECT c.id, c.fulltext, c.introtext FROM #__k2_items AS c WHERE id=\''.$shParams.'\''; else $sql = 'SELECT c.id, c.fulltext, c.introtext FROM #__content AS c WHERE id=\''.$shParams.'\'';
That´s all. Sef url´s with uberpagebreak tabs and no duplicates due to the plugin. Now I am working on k2 comments links (when comments pagination is present and uberpagebreak present in the item). But this looks easier...
I hope this simple way to solve this problem works for other people, it took long time to find it out (i am not a professional developer..) I think sh404sef configuration doesn´t matter for this solution, but I´m not sure about this. I´ll test.
Please Log in or Create an account to join the conversation.
- Adamo
-
Topic Author
- Offline
- Junior Member
- Posts: 29
Please Log in or Create an account to join the conversation.
- BBC
-
- Offline
- Platinum Member
- Posts: 663
For some time, but when you purge URL cache and Joomla cache same and even worst can happen again. Unstable.
I will see how to make nice buttons in Jooma default pagebreak. Then i don´t need some "Uberpagebreak".
Just complicating things.
Please Log in or Create an account to join the conversation.
- BBC
-
- Offline
- Platinum Member
- Posts: 663
forum.joomla.org/viewtopic.php?f=471&t=511990&p=2129357#p2129357
Please Log in or Create an account to join the conversation.
- BBC
-
- Offline
- Platinum Member
- Posts: 663
demo.getk2.org/en/category-blog/item/49-uberpagebreak
Please Log in or Create an account to join the conversation.
- BBC
-
- Offline
- Platinum Member
- Posts: 663
It is not so easy to fix that problem. Developers from sh404SEF would put this few lines of code long ago if it would be enough. But they did not do it, and there is sure reason for that.
Please Log in or Create an account to join the conversation.
- Francis Darren
-
- Offline
- Senior Member
- Posts: 55
Please Log in or Create an account to join the conversation.
- AdrianK
-
- Offline
- Senior Member
- Posts: 46
Please Log in or Create an account to join the conversation.