Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
#1 2006-05-05 11:03:50
- Sootah
- Member
- Registered: 2006-05-04
- Posts: 27
Why can't you (or better yet, how CAN you) add a custom permalink?
I’ve got most issues in my other thread figured out, but I was wondering why you can’t add your own custom permalink structure? With WordPress they give you a blank textbox that you can throw /%date%/%category%/%posttitle% or whatever into to make the perma structure the way you want it.
I want to add this: /section/category/posttitle as a possibility. The URL works now, thanks to the plugin in the other thread, but now I need permas to do what I want em to.
Thanks a million. -Kevin
Offline
#2 2006-05-05 12:18:53
- els
- Moderator
- From: The Netherlands
- Registered: 2004-06-06
- Posts: 7,458
Re: Why can't you (or better yet, how CAN you) add a custom permalink?
You can also have a look at gbp_faux_static. This plugin is a bit more complicated than sgb_url_handler, but it lets you set custom permlink formats.
Offline
#3 2006-05-05 12:36:21
- Sootah
- Member
- Registered: 2006-05-04
- Posts: 27
Re: Why can't you (or better yet, how CAN you) add a custom permalink?
Ultimately I’d like to not have to rely on plugins or that to do this. Can’t I edit some of the source files?
I found that in /include/txp_prefs.php I could add <code>“section_category_title” => gTxt(“section_category_title”),</code> into the function permlinkmodes and it’d show up on the preferences page, although when selected it did nothing. It also didn’t display in the correct format. (all others are /section/id/title, my addition showed up as section_category_title)
The problem is that I don’t know where the rest of the code is hiding since TxP has sooooo many different files. That’s the one thing that is irritating with a new CMS or any other large project is hacking it a bit is overly difficult at first because you never know where the necc. code is to edit.
Offline
#4 2006-05-05 13:34:34
- Sootah
- Member
- Registered: 2006-05-04
- Posts: 27
Re: Why can't you (or better yet, how CAN you) add a custom permalink?
Hmm.. Closer. I’ve got it trying to use it, but I need to know where the function is called from…
taghandlers.php has more stuff in it. I’ve changed the following:
switch($permlink_mode) { case ‘section_category_title’: if ($prefs[‘attach_titles_to_permalinks’]) { return hu.”$section/$category/$url_title”; }else{ return hu.”$section/$category/”; }
What other files need playing with?
The main reason I don’t want to just use a plugin is that I’d have to go edit every template ever to use the modified tags. If I get the urge in the future to change the layout of the site I don’t want to have to remember to go to every different page that I alter and put in the custom permalink tags. If I can make TxP just do it natively then life will be super easy.
Offline
#5 2006-05-05 13:38:33
- els
- Moderator
- From: The Netherlands
- Registered: 2004-06-06
- Posts: 7,458
Re: Why can't you (or better yet, how CAN you) add a custom permalink?
I see you already found function permlinkurl
in /publish/taghandlers.php. Mind that hacking the code means you’ll have to do that every time you upgrade.
Offline
#6 2006-05-05 13:41:31
- Sootah
- Member
- Registered: 2006-05-04
- Posts: 27
Re: Why can't you (or better yet, how CAN you) add a custom permalink?
I know, but that’s not too big of a deal one I know where it’s all at. Besides, hopefully they’ll add native section/category/title support in the future.
Where does $thisarticle get declared? It’s what appears to be the root of the data so far.
Why isn’t $category passed along with the other stuff?
Offline
Re: Why can't you (or better yet, how CAN you) add a custom permalink?
Sootah,
Its more likely section/section/ support will be added in the future, but hey, go for it.
:)
Matthew
- I am Squared Eye and I
am launchinghave launched Pattern Tap
Offline
#8 2006-05-05 14:00:27
- Sootah
- Member
- Registered: 2006-05-04
- Posts: 27
Re: Why can't you (or better yet, how CAN you) add a custom permalink?
Ahhhhhh, SOOO close!
I’ve got the URL displaying correctly in the path for the link, BUT when you click it it goes nowhere. Why is that?
Here’s the code I’ve changed so far and in what files:
From taghandlers.php:
added another if statement, made it grab category1, and then added a switch to check for the “section_category_title” permlink_mode.
<code> if (empty($category1)) $category1 = $Category1;
switch($permlink_mode) { case ‘section_category_title’: if ($prefs[‘attach_titles_to_permalinks’]) { return hu.”$section/$category1/$url_title”; }else{ return hu.”$section/$category1/”; }</code>
From txp_prefs.php:
added the following line
<code>“section_category_title” => gTxt(“section_category_title”),</code>
into the permlinkmodes function.
There are only two issues. The permalink, as far as HTML is concerned works. If I put my mouse over the link it formats it just the way I want it to.
However, the two issues are
1: The link doesn’t actually WORK. It just ends up reloading the same page as it was on.
2: The “Permanent Link Mode” drop down box displays my addition with underscores, whereas the rest of the selections have /‘s. I’m not sure where to edit it to change that, and perhaps they are part of the same problem. (example: my addition displays as “section_category_title” and the next down displays properly as “section/id/title”)
Offline
#9 2006-05-05 15:00:55
- els
- Moderator
- From: The Netherlands
- Registered: 2004-06-06
- Posts: 7,458
Re: Why can't you (or better yet, how CAN you) add a custom permalink?
I can only answer #2 for you. You’ll have to add section_category_title => /section/category/title
to your language file and re-install it, or add it in the language table (txp_lang).
Offline
#10 2006-05-05 15:02:31
- Sootah
- Member
- Registered: 2006-05-04
- Posts: 27
Re: Why can't you (or better yet, how CAN you) add a custom permalink?
Yeah, I found that one a little while ago. However, it still doesn’t display it properly for some reason.
Offline
#11 2006-05-05 15:05:14
- Sootah
- Member
- Registered: 2006-05-04
- Posts: 27
Re: Why can't you (or better yet, how CAN you) add a custom permalink?
I’ve got it working now, but not entirely the way I want it.
The permalink works, but only if the url_handler plugin is activated. Why can’t I get it going without it?
Offline
#12 2006-05-05 15:08:35
- Sootah
- Member
- Registered: 2006-05-04
- Posts: 27
Re: Why can't you (or better yet, how CAN you) add a custom permalink?
Oh, more editing was done:
publish.php – added to the switch($permalink_mode)
<code> case ‘section_category_title’:
if (empty($u2)) {
$out[‘s’] = (ckEx(‘section’,$u1)) ? $u1 : ‘’;
$is_404 = empty($out[‘s’]);
}
else {
$rs = lookupByTitleSection($u2,$u1);
$out[‘id’] = $rs['ID'];
$out['s'] =
$rs[‘Section’];
$is_404 = (empty($out[‘s’]) or empty($out[‘id’]));
}
break;</code>
and in the lang/en-gb I added
<code> section_category_title => /section/category/title </code>
Now if only I could get this to work without a plugin I’d be super happy. Also the fact that even with the above line of code in the lang file it still doesn’t display properly kinda irks me.
Offline