Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#631 2014-07-10 17:17:21

colak
Admin
From: Cyprus
Registered: 2004-11-20
Posts: 9,367
Website GitHub Mastodon Twitter

Re: gbp_permanent_links

Hi Chris

I think that this is exactly how it should work (without the trailing slash). The way I understand the schema is that articles end up without the slash whereas sections and categories come with it. I guess sections and categories are thought of as directories and individual articles as a single html page.


Yiannis
——————————
NeMe | hblack.art | EMAP | A Sea change | Toolkit of Care
I do my best editing after I click on the submit button.

Offline

#632 2014-12-22 07:36:08

admi
Member
From: BY
Registered: 2007-12-10
Posts: 145
Website

Re: gbp_permanent_links

Two years ago I tried the plugin and somebody helped me with the instruction:

Create a new rule:
1. Permalink rule: section/category/title
2. In Settings: a name (like “section-category-title” or whatever) and precedence = 100
3. In Conditions: Within section “News”
Now, create another rule:
1. Permalink rule: section/title
2. In Settings: a name (like “section-title” or whatever) and precedence = 90
3. In Conditions: Within section “News”
4. In Redirections: Redirect this permanent link to: section-category-title.
That’s all. (I think)
I would like to see other examples, :D

I remember that it workred back then Ok. However today I decided to use gbp_peramlinks, followed the instruction and when I visit an indivifual article I got either 301 page not found or so called cyclic redired. What can be a problem? Do I have to use tags like txp:gbp_permlink…..

One of the problem is that I cannot find any clear-cut instruction. And this 60 page long topic may have the answer but so easy to get lost here.

Offline

#633 2014-12-22 12:31:24

qrayg
Member
From: USA
Registered: 2004-08-27
Posts: 81
Website

Re: gbp_permanent_links

@admi
Have you set your TXP Permanent Link Mode option to “?=messy” in Preferences?

Offline

#634 2014-12-22 18:14:13

admi
Member
From: BY
Registered: 2007-12-10
Posts: 145
Website

Re: gbp_permanent_links

qrayg wrote #286804:

@admi
Have you set your TXP Permanent Link Mode option to “?=messy” in Preferences?

yes. i have tried all options. do you think that the rule i posted above is enough to get the desired urls – section/category/title?

Also why is a slash at the end of individual article url?

Offline

#635 2014-12-22 18:39:15

els
Moderator
From: The Netherlands
Registered: 2004-06-06
Posts: 7,458

Re: gbp_permanent_links

I’m not sure you need the second rule. I’ve used the first rule in the past without needing the second one. You could try if deleting the second rule helps.

And there is a setting in the plugin preferences that lets you omit the trailing slash.

Offline

#636 2014-12-24 08:12:33

admi
Member
From: BY
Registered: 2007-12-10
Posts: 145
Website

Re: gbp_permanent_links

Els wrote #286807:

I’m not sure you need the second rule. I’ve used the first rule in the past without needing the second one. You could try if deleting the second rule helps.

And there is a setting in the plugin preferences that lets you omit the trailing slash.

well. it does need that. I tried a fresh txp installation – and it works ok! I am not sure, may be the secton I need with that link pattern should be made frontpage or default??? hard to say, i have to see.

Offline

#637 2015-06-25 12:25:46

uli
Moderator
From: Cologne
Registered: 2006-08-15
Posts: 4,316

Re: gbp_permanent_links

CAUTION:

CHANGING PREFERENCES (actually: simply saving these) SEEMS TO DELETE ALL YOUR RULES!

The only way around this seems to first set prefs, and then build the rules. If you succeeded any other way or have patched the plugin: Please post!

Sorry, will surely be something on my side that I’ve yet to find out: Even leaving gbp_pl and returning deletes all the rules. (Are they saved at all? Hrrm.)

Last edited by uli (2015-06-25 12:43:10)


In bad weather I never leave home without wet_plugout, smd_where_used and adi_form_links

Offline

#638 2015-06-25 13:24:06

uli
Moderator
From: Cologne
Registered: 2006-08-15
Posts: 4,316

Re: gbp_permanent_links

OK, I set up a brandnew DB. Now, only gbp_pl + lib installed on TXP 4.5.7 (Diagnostics: “All checks passed!”), produces this while skipping from gbp_pl tab to ~ tab:

A problem occurred while loading the plugin: gbp_permanent_links -> Notice: unserialize(): Error at offset 5 of 910 bytes on line 177

A problem occurred while loading the plugin: gbp_permanent_links -> Notice: unserialize(): Error at offset 5 of 903 bytes on line 177

The only occurrence of unserialize here in this topic has to do with using a regex which I’m not doing. Have I missed something stupid? Doesn’t it work any longer on MAMP?

Just for completeness’ sake: I still can’t save any rule, like on my previous setup/DB/installation, but I’m getting the errors that I didn’t have on my previous setup.


In bad weather I never leave home without wet_plugout, smd_where_used and adi_form_links

Offline

#639 2015-08-04 19:59:11

miles
Member
From: Plymouth
Registered: 2008-05-22
Posts: 78
Website

Re: gbp_permanent_links

Does this plugin no longer work on 4.5.7? As I can’t get any rules to save? It says its saved but doesn’t show up in the list

Offline

#640 2015-08-04 20:18:32

uli
Moderator
From: Cologne
Registered: 2006-08-15
Posts: 4,316

Re: gbp_permanent_links

miles wrote #293949:

Does this plugin no longer work on 4.5.7? As I can’t get any rules to save? It says its saved but doesn’t show up in the list

Not quite sure which version broke the plugin (for me, too), see my two previous posts, I don’t even succeed in installing it when it’s a brand new database. So I’d say you must be on an updated version of TXP.


In bad weather I never leave home without wet_plugout, smd_where_used and adi_form_links

Offline

#641 2015-09-17 07:20:45

Gallex
Member
Registered: 2006-10-08
Posts: 1,331

Re: gbp_permanent_links

is there working alternative for this plugin? cause it looks like it doesn’t work on 4.5.7 anymore….

Offline

#642 2016-02-23 15:34:42

michaelkpate
Moderator
From: Avon Park, FL
Registered: 2004-02-24
Posts: 1,379
Website GitHub Mastodon

Re: gbp_permanent_links

uli wrote #292071:

A problem occurred while loading the plugin: gbp_permanent_links -> Notice: unserialize(): Error at offset 5 of 910 bytes on line 177...

The only occurrence of unserialize here in this topic has to do with using a regex which I’m not doing. Have I missed something stupid? Doesn’t it work any longer on MAMP?

I have been trying to get this to work with a recent version. When you use the Build option, you can create a new rule and it claims that it is successfully saved, but it never does.

I suspect the problem lies in here:

function post_save_permlink () {
		// The function posts or saves a permanent link to txp_prefs

		extract(gpsa(array('step', gbp_id)));

		// Grab the user defined settings from the form POST data
		$settings = gpsa(array(
			'pl_name', 'pl_precedence', 'pl_preview',
			'con_section', 'con_category',
			'des_section', 'des_category', 'des_page',
			'des_permlink', 'des_feed', 'des_location',
		));

		// Remove spaces from the permanent link preview
		$settings['pl_preview'] = preg_replace('%\s+/\s*%', '/', $settings['pl_preview']);

		// Explode the separated string of serialize components - this was made by JavaScript.
		$serialize_components = explode(gbp_separator, rtrim(gps('components'), gbp_separator));

		// Unserialize the components
		$components = array();
		foreach ($serialize_components as $c)
			$components[] = unserialize(stripslashes($c));

		// Complete the permanent link array - this is exactly what needs to be stored in the db
		$permlink = array('settings' => $settings, 'components' => $components);

		// Save it
		$this->set_preference($id, $permlink, 'gbp_serialized');

		$this->parent->message = messenger('', $settings['pl_name'], 'saved');
	}

Any PHP Gurus notice anything that stands out?

Offline

#643 2016-06-22 12:31:39

Destry
Member
From: Haut-Rhin
Registered: 2004-08-04
Posts: 4,912
Website

Re: gbp_permanent_links

  • Txp 4.6 beta
  • mysql 5.7.13
  • php 7.0.7

I know we’re going to need to rethink our publishing build on this, but at CSF we’ve borrowed the /people section architecture that Bloke designed in the TXP Mag site to handle site contributors/profile pages, etc, which uses some gbp mechanics. Ideally we’ll want to drop use of gbp plugins entirely, but in the meantime…

I’ve just updated the CSF site on local (different from the one’s I’ve updated and wrangled the last couple of days). I didn’t get any errors in the Languages panel, as I was seeing before, but the front-side was not displaying any article content. The layout and presentation was intact, but no content.

Throwing into debug mode gave me these errors:

A problem occurred while loading the plugin: gbp_admin_library -> 8192: Methods with the same name as their class will not be constructors in a future version of PHP; GBPPlugin has a deprecated constructor on line 6
textpattern/lib/txplib_misc.php:1369 eval()
textpattern/lib/txplib_misc.php:1391 load_plugin()
textpattern/lib/txplib_misc.php(1783) : eval()'d code:9 require_plugin()
textpattern/lib/txplib_misc.php:1783 eval()
textpattern/publish.php:169 load_plugins()
index.php:104 include()

General error Notice: Undefined index: permalink_title_format on line 276
textpattern/lib/txplib_misc.php:1896 PermanentLinks->_textpattern()
textpattern/publish.php:545 callback_event()
index.php:105 textpattern()

General error Warning: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead on line 284
textpattern/lib/txplib_misc.php(1783) : eval()'d code:284 preg_replace()
textpattern/lib/txplib_misc.php:1896 PermanentLinks->_textpattern()
textpattern/publish.php:545 callback_event()
index.php:105 textpattern()

Oi!

Offline

#644 2016-06-22 14:17:32

michaelkpate
Moderator
From: Avon Park, FL
Registered: 2004-02-24
Posts: 1,379
Website GitHub Mastodon

Re: gbp_permanent_links

First Error:

Plugin Code

class GBPPlugin {
	// Redacted
        :

	// Constructor
	function GBPPlugin ($title = '', $event = '', $parent_tab = '')

Cause

PHP 4 style constructors (methods that have the same name as the class they are defined in) are deprecated, and will be removed in the future. PHP 7 will emit E_DEPRECATED if a PHP 4 constructor is the only constructor defined within a class. Classes that implement a __construct() method are unaffected. – Deprecated features in PHP 7.0.x

Second Error:

Plugin Code

						if ($prefs['permalink_title_format']) {
							$mt_search = array('/_/', '/\.html$/');
							$mt_replace = array('-', '');
						} else {
							$mt_search = array('/(?:^|_)(.)/e', '/\.html$/');
							$mt_replace = array("strtoupper('\\1')", '');
						}

Cause

Relying on the default value of an uninitialized variable is problematic in the case of including one file into another which uses the same variable name. It is also a major security risk with register_globals turned on. E_NOTICE level error is issued in case of working with uninitialized variables, however not in the case of appending elements to the uninitialized array. isset() language construct can be used to detect if a variable has been already initialized. – PHP: Notice: undefined index

Third Error (multiple locations)

	$settings['pl_preview'] = preg_replace('%\s+/\s*%', '/', $settings['pl_preview']);

	$req = preg_replace('%\?[^\/]+$%', '', $req);

	? preg_replace($mt_search, $mt_replace, $uri_c)

Cause

As of PHP 5.5 the preg_replace modifier /e is deprecated. When using it, you will get an deprecated message like E_DEPRECATED >> preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead. The update is quite easy.- Replace preg_replace with preg_replace_callback for PHP 5.5

Interestingly, there is also one occurrence of preg_replace_callback in the plugin code already.

Edit: Now that I read up on this more none of those are using the /e modifier. So I don’t get what is triggering this.

		$html = preg_replace_callback(
			'%href="('.hu.'|\?)([^"]*)"%',
			array(&$this, '_pagelinkurl'),
			$html
		);

Last edited by michaelkpate (2016-06-22 14:21:09)

Offline

#645 2016-07-23 14:40:27

planeth
Plugin Author
From: Nantes, France
Registered: 2009-03-19
Posts: 239
Website GitHub Mastodon

Re: gbp_permanent_links

Regarding the problem of :
E_DEPRECATED >> preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead.

This is a ugly work-around for those needing it. No time to dive into the whole plugin reasonning.
Around the line 276

            //
            if ($prefs['permlink_format']) {
              $mt_search = array('/_/', '/\.html$/');
              $mt_replace = array('-', '');
              $mt_uri_c = $this->pref('redirect_mt_style_links')
                ? preg_replace($mt_search, $mt_replace, $uri_c)
                : '';
            } else {
              $mt_search = array('/(?:^|_)(.)/', '/\.html$/');
              $mt_replace = array("strtoupper('\\1')", '');
              $mt_uri_c = $this->pref('redirect_mt_style_links')
                ? preg_replace_callback(
                    $mt_search, 
                    function($matches) { return strtoupper($matches[1]); },
                    $uri_c)
                : '';
            }

Edited to reflect new pref : permlink_format in replacement of permalink_title_format

Last edited by planeth (2016-07-23 15:16:05)

Offline

Board footer

Powered by FluxBB