Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2006-07-14 15:03:35

graeme
Plugin Author
Registered: 2004-06-21
Posts: 337
Website

Improvement to pagelinkurl()

Can I request a new feature please.

At the moment the custom_url_func preference is only used in permlinkurl(). I would really like to see it, or a different preference, be used in the same way in pagelinkurl().

Through a completely new version my gbp_faux_static plugin which I’m currently working it will let users not only have customisable permanent links formats to articles, but also all other the tags such as <txp:section_list />, <txp:newer /> etc… will also be able to use user defined pagelink formats aswell.

Cheers

Offline

#2 2006-07-14 17:55:34

Mary
Sock Enthusiast
Registered: 2004-06-27
Posts: 6,236

Re: Improvement to pagelinkurl()

…user defined pagelink formats…

That’s already possible. See lines 1489 & 1490:

if (isset($prefs['custom_url_func']) and is_callable($prefs['custom_url_func']))
	return call_user_func($prefs['custom_url_func'], $article_array);

:)

Offline

#3 2006-07-14 21:03:01

graeme
Plugin Author
Registered: 2004-06-21
Posts: 337
Website

Re: Improvement to pagelinkurl()

Lines 1489 and 1490 refer to permlinkurl() I’m requesting the same for pagelinkurl() in txplib_misc.php

:-)

Offline

#4 2006-07-14 22:03:25

Mary
Sock Enthusiast
Registered: 2004-06-27
Posts: 6,236

Re: Improvement to pagelinkurl()

Oh duh.

Out of curiosity, what kind of custom urls (section_list, etc)?

Offline

#5 2006-07-15 00:29:33

graeme
Plugin Author
Registered: 2004-06-21
Posts: 337
Website

Re: Improvement to pagelinkurl()

Mary wrote:

Out of curiosity, what kind of custom urls (section_list, etc)?

Well, I guess that is best shown via a screen grab….

As you can see, the user can add and remove the different components of the permanent link. The orange component is the one selected, and from the popup you change it’s type (section, category, url-title, date, page number, serach request, author, custom fields, etc…).

There are also options to use these permanent link under certain conditions. E.g. you can specify all the links to certain section to be a different format. Or to use a certain permanent link when tags (<txp:newer>, <txp:older>, etc..) link to article lists with page numbers.

And a lot more…

So in reality it is not just permanent links but pages links as well. Hence the request.

And as most the internal txp tags, like <txp:section_list /> use pagelinkurl() I could intercept all of these and output urls to the user’s specification.

Mary, I hope that answers your question.

Offline

#6 2006-12-06 21:59:12

graeme
Plugin Author
Registered: 2004-06-21
Posts: 337
Website

Re: Improvement to pagelinkurl()

Would you be able to let me know if this feature request is being considered? It’s been a while.

The plugin I referred to has been released a while back. I’ve come up with a very hacky work around which clearly isn’t ideal.

I’m using a callback to textpattern() to make a pseudo textpattern_end callback (by duplicating code from textpattern() and using die()). Within textpattern_end I capture an output buffer and run preg_replace_callback on the links which I have forced into messy format, as that is the only way to capture the variables. Ugh.

Like I said very hacky, it’s also quite slow.

What do you think the chances are?

Offline

#7 2006-12-10 23:27:16

zem
Developer Emeritus
From: Melbourne, Australia
Registered: 2004-04-08
Posts: 2,579

Re: Improvement to pagelinkurl()

What do you think the chances are?

Zero unless someone contributes a patch. Slim in the 4.0 branch, unless it’s very simple and low risk.


Alex

Offline

#8 2006-12-12 05:30:03

Mary
Sock Enthusiast
Registered: 2004-06-27
Posts: 6,236

Re: Improvement to pagelinkurl()

Definitely not for 4.0.x.

It’s not difficult to add the exact same thing, but, I don’t know whether that’d make any difference in how easy to modify the page urls, having them use the same function. Could do it by having a first parameter being a “type” variable.

i.e:

// in permlinkurl()
if (isset($prefs['custom_url_func']) and is_callable($prefs['custom_url_func'])) {
	return call_user_func($prefs['custom_url_func'], 'article', $article_array);
}

// in pagelinkurl ()
if (isset($prefs['custom_url_func']) and is_callable($prefs['custom_url_func'])) {
	return call_user_func($prefs['custom_url_func'], 'page', $keys);
}

// what your new custom function might look like
function my_custom_function($type, $keys) {
	if ($type == 'article') {
		//
	} elseif ($type == 'page') {
		//
	}
}

That way, it’s still only one preference, we could extend to further types extremely easily in the future if we ever need them (just increase possible $types, not adding new prefs and functions), and you could either use just the one function, or you could use it as a kind of master function that calls others.

How does that sound?

Offline

Board footer

Powered by FluxBB