Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#265 2005-08-15 18:33:17

andreas
Member
Registered: 2004-02-28
Posts: 453
Website

Re: [plugin] [ORPHAN] sgb_url_handler - support all url variations at the same time

You can edit what the permlink returns if you open the plugin code. I don’t know exactly where you can make changes but I’m pretty sure that you can.

Offline

#266 2005-08-15 19:01:14

bauhouse
Archived Plugin Author
From: Abbotsford, BC Canada
Registered: 2004-06-29
Posts: 68
Website

Re: [plugin] [ORPHAN] sgb_url_handler - support all url variations at the same time

My mistake. The permlink output is working fine, outputting the category name. I just forgot about my modification to output the name of category2 if it existed before output category 1. At around line 276, you can modify the code to look like this if you would rather the plugin output the name of category2:

bc.. $r = array($a[‘url_title’], $a[‘section’], urlencode(((isset($a[‘category2’])) ? $a[‘category2’] : $a[‘category1’])), $a[‘id’], date(‘Y’, $a[‘posted’]), date(‘m’, $a[‘posted’]), date(‘d’, $a[‘posted’]), ‘/’);

Category1 and category2 have been switched around in the code. I always put the more specific category in category2, and I would rather that output in the permlink url.

Offline

#267 2005-08-15 20:22:48

bauhouse
Archived Plugin Author
From: Abbotsford, BC Canada
Registered: 2004-06-29
Posts: 68
Website

Re: [plugin] [ORPHAN] sgb_url_handler - support all url variations at the same time

Well, I’ve got the right permlink form now, but the link is not able to select the right article, though it selects the right category. I suppose Jeremie is right.

It seems the only way the section/category/title url scheme worked for me before was because I had forced Textpattern to recognize it by hacking the source.

Last edited by bauhouse (2005-08-15 20:35:05)

Offline

#268 2005-08-16 08:34:12

jonhicks
Member
From: Oxfordshire UK
Registered: 2004-03-22
Posts: 256
Website

Re: [plugin] [ORPHAN] sgb_url_handler - support all url variations at the same time

> Andrew wrote:

> bq. reid wrote: …until there’s a workable way to redirect old schemes to new ones, I’m stuck with /section/id/title.

> That’s precisely the reason why I haven’t switched url schemas since the new formats were made available.
And exactly why I wished I hadn’t rushed in to change over to section/title….


Cheers,
Jon VC#9

Offline

#269 2005-08-16 09:15:07

boblet
Member
Registered: 2005-08-08
Posts: 53

Re: [plugin] [ORPHAN] sgb_url_handler - support all url variations at the same time

Hi all, after much flailing around I’ve managed to get section/category/title urls working using v4.0r797. The important things for me were:
  • finding the instructions! (always a good start ;-)
    also, clicking the admin > plugins > help link (to the right of the plugin) actually gives a decent help page.
  • following the guide to hacking in support for this scheme:
    • note that where he’s written he added section_title I think he means he added section_category_title, as section_title is already present.
    • Also note there’s no language text files anymore, and you’ll need to add a new row to the database’s txplang table. I duplicated id#342 name=section_title and changed to name=section_category_title and data=/section/category/title (lang and event fields stay the same, hopefully lastmod will automatically have the current timestamp inserted, and you’ll probably need to give it an incremental id)
  • changing the order of preferred url schemes in admin > plugins > edit plugin so that <pre>$schemes[‘section_category_title’] = ‘/%section%/%category%/%title%’;</pre> is at the top of the list
  • changing instances of <txp:permlink> to <txp:sgb_url_handler_permlink> in content > forms and content > pages

have fun

peace – boblet

PS I wonder how to escape % symbols in @ code blocks?

Last edited by boblet (2005-08-16 09:18:13)

Offline

#270 2005-08-16 15:10:46

bauhouse
Archived Plugin Author
From: Abbotsford, BC Canada
Registered: 2004-06-29
Posts: 68
Website

Re: [plugin] [ORPHAN] sgb_url_handler - support all url variations at the same time

Thanks for the instructions, boblet. I must still be missing something, though. I’m still unable to select the correct article within the category. One thing I discovered, though, is that you don’t need to modify the database manually if you have a language file in the textpattern/lang directory.

  • I made the modification to the textpattern/lang/en-gb.txt file to add this text to the language file (adding the second line after the first line — line 400):
    <pre>section_title => /section/title
    section_category_title => /section/category/title
    </pre>
  • Go to admin > preferences > manage languages and click on the “Install from file (experts only)” link at the bottom of the page.
  • This should give you a list of the files in the textpattern/lang directory. Click on the “install” link under the column heading “Install from file”. This appears to add a row at the end of the lang table in the database for the additional url scheme.

Offline

#271 2005-08-16 15:22:32

boblet
Member
Registered: 2005-08-08
Posts: 53

Re: [plugin] [ORPHAN] sgb_url_handler - support all url variations at the same time

Hey Bauhouse,

one thing, you don’t have article names that have periods in them right? I’m actually trying to get about.en.php or about.en article titles going (for content negotiation), but get 404 errors. Using alphanumeric, – and _ works ok for me though. I think I need to edit one of the plugins huh.

I upgraded via SVN from RC4, and am running localhost on new versions of everything (apache2, php5) by the way – might not work for me either once I try to go live

peace – boblet

PS mmm, awabi sute-ki! ;-)

Offline

#272 2005-08-16 15:36:39

bauhouse
Archived Plugin Author
From: Abbotsford, BC Canada
Registered: 2004-06-29
Posts: 68
Website

Re: [plugin] [ORPHAN] sgb_url_handler - support all url variations at the same time

The other thing is that the hacks may not really be necessary, since you can get the plugin working for individual sections by editing the plugin with the following configuration for the home page only:

<pre>
$sections[‘default’] = ‘section_category_title’;
</pre>

So you could theoretically have a different url scheme for each section by editing the plugin and adding something like this:

<pre>
$sections[‘default’] = ‘section_category_title’;
$sections[‘articles] = ‘section_date_title’;
$sections[‘about’] = ‘title_only’;
$sections[‘downloads’] = ‘_file’;
</pre>

Hacking just makes it easier to choose the section/category/title permlink mode from the preferences tab.

Last edited by bauhouse (2005-08-16 15:37:28)

Offline

#273 2005-08-16 15:46:34

bauhouse
Archived Plugin Author
From: Abbotsford, BC Canada
Registered: 2004-06-29
Posts: 68
Website

Re: [plugin] [ORPHAN] sgb_url_handler - support all url variations at the same time

boblet, thanks for the tip. I don’t have periods in my article names. I am also running locally with the latest, except for apache2, and I can actually change the url scheme for the section to $sections['portfolio'] = 'section_date_title'; and $sections['portfolio'] = 'title_only'; and it works great! The only scheme that doesn’t appear to be working for me is the one I want: $sections['portfolio'] = 'section_category_title';.

Offline

#274 2005-08-26 13:59:29

tinyfly
Member
From: Dallas, Texas
Registered: 2004-05-10
Posts: 462
Website

Re: [plugin] [ORPHAN] sgb_url_handler - support all url variations at the same time

I have a weird problem. I am using rss_suparchive in my news section and have a years list. If I click on 2005 all 2005 articles should show but they don’t even though I have 32 2005 articles. (the url is www.mydomain.com/news/2005). If I click on 2004 all 39 2004 articles do apear. (the url is www.mydomain.com/news/2004). 2003 works also. If I disable sgb_url_handler 2005 works fine.

Any thoughts?

Last edited by tinyfly (2005-08-26 14:00:12)

Offline

#275 2005-08-27 05:38:10

boblet
Member
Registered: 2005-08-08
Posts: 53

Re: [plugin] [ORPHAN] sgb_url_handler - support all url variations at the same time

After updating via SVN some of my changes to enable /section/category/title URLs (as per previously mentioned instructions) were removed, specifically in <code>taghandlers.php</code> this should appear after <code>if (empty($thisid)) $thisid = $ID;</code>:
<pre><code>if (empty($category)) { $Category1 = (!empty($Category1)) ? $Category1 : $category1; $Category2 = (!empty($Category2)) ? $Category2 : $category2; $category = (!empty($Category1)) ? $Category1 : $Category2;
}
</code></pre>

Next up, I’ve been trying to get language suffixes going so I can use Apache content negotiation. I discovered that with this plugin turned off that periods in “url-only title” work for most main clean URL modes. Hell, even slashes are accepted for modes with an ID number (<em><strong>!?</strong> arbitrary site structure plugin, anyone?</em> ;-) Unfortunately with this plugin on, any periods in the url-ony title will give 404s. So a quick scan of the plugin code and I found the function <code>sgb_url_handler_schemes_to_patterns</code>. I added a “\.” to the title array (first one) and we’re in business! It’s on line 122 or thereabouts.
<code>return str_replace(array(‘title’, ‘section’, ‘category’, ‘id’, ‘year’, ‘month’, ‘day’, ‘string’, ‘number’, ‘_author’, ‘_category’, ‘_section’, ‘_file’, ‘/’), array(‘([A-Za-z0-9-_\.])*’, ‘([A-Za-z0-9-_])*’, ‘([A-Za-z0-9-_\s])*’, ‘(\d)*’, ‘\d{4}’, ‘\d{2}’, ‘\d{2}’, ‘([A-Za-z0-9-_])*’, ‘(\d)*’, strtolower(gTxt(‘author’)), strtolower(gTxt(‘category’)), strtolower(gTxt(‘section’)), strtolower(gTxt(‘file_download’)), ‘\/’), $a);</code>

I now have /section/category/title.suffix clean URLs, eg /portfolio/print/sakura-flyer.en and /portfolio/print/sakura-flyer.jp. Cue the heavenly chorus!

<strong>Update</strong>: hrmm – it looks like the sgb_url_handler will 404 any titles lacking a language extension (rather than Apache taking over and redirecting to .en or .jp based on content negotiation), so I’m not there yet. Any ideas? I guess I’ll have to wait for Biff or someone who understands his code to offer a suggestion…

Last edited by boblet (2005-08-27 15:04:11)

Offline

#276 2005-08-27 16:37:35

bauhouse
Archived Plugin Author
From: Abbotsford, BC Canada
Registered: 2004-06-29
Posts: 68
Website

Re: [plugin] [ORPHAN] sgb_url_handler - support all url variations at the same time

boblet suggested I try turning on debug to see what’s happening with this plugin. I suppose I should have tried this before. It throws a lot of errors and warnings. Here are the top three:

<pre>
A problem occured while loading the plugin: sgb_url_handler -> Notice: Undefined index: PATH_INFO
A problem occured while loading the plugin: sgb_url_handler -> Notice: Undefined index: id
A problem occured while loading the plugin: sgb_url_handler -> Notice: Undefined index: category2
</pre>

And then there are warnings like this:

<pre>
Notice: Undefined index: mode in /Library/WebServer/Documents/dev/bauhouse.ca/public_html/textpattern/lib/txplib_misc.php(429) : eval()’d code on line 289
Notice: Undefined index: section in /Library/WebServer/Documents/dev/bauhouse.ca/public_html/textpattern/lib/txplib_misc.php(429) : eval()’d code on line 289
Notice: Undefined index: scheme in /Library/WebServer/Documents/dev/bauhouse.ca/public_html/textpattern/lib/txplib_misc.php(429) : eval()’d code on line 289
</pre>

…where these three errors are repeated several times (probably for each time the sgb_url_handler_permlink tag appears on the page).

With a clean install of Textpattern 4.0 (deanload), installing the sgb_url_handler plugin returns the following error in debug mode: A problem occured while loading the plugin: sgb_url_handler -> Notice: Undefined index: PATH_INFO

boblet, are you getting similar errors?

Last edited by bauhouse (2005-08-27 16:43:28)

Offline

Board footer

Powered by FluxBB