[Register]
Powered by Elgg

Plugins :: Blog :: Updated uri plugin (friendly url's)

June 01, 2007

Hi, i added to plugin catalog and updated the uri plugin. 

Note: this plugin needs some modification into the blog code and apply some patchs, was tested on linux environment if you are on windows need to look for some utility to apply the patchs.

Download 

I made the install instructions simple as possible, but any feedback will be helpful.

-- uri plugin for elgg

This plugin make the posibility to use custom url's for posts.
For example, if you have a post title like 'Hello World' (with id 12)
the default url is http://.../weblog/12.html
but with this plugin you got http://.../weblog/hello-world
or you can customize to http://.../weblog/post/hell-world.xhtml

Tested against elgg v0.8rc2.

=== To install:

== Step 1 - Copy mod/uri to your [elgg_dirroot]/mod/

== Step 2 - In your browser, login as 'news' users and go to:
http://domain/elgg/mod/uri/dbsetup.php

== Step 3 - The populate your uri's, go to:
http://domain/elgg/mod/uri/populate.php

== Step 4 - Modify mod/blog/view_post.php (your elgg will still functional)

- around line 21, the code line:

    $post = optional_param('post',0,PARAM_INT);

- comment it and add the line:

    //$post = optional_param('post',0,PARAM_INT);
    $post = run('mod:uri:getid');

== Step 5 - Modify your .htaccess (your elgg will still functional)

Be carefull on this, replace (or comment) the next two lines:

RewriteRule ^[A-Za-z0-9]+\/weblog\/([0-9]+)\.html$ mod/blog/view_post.php?post=$1
RewriteRule ^[A-Za-z0-9]+\/weblog\/([0-9]+)\.html.([0-9]+)$ mod/blog/view_post.php?post=$1&commentpage=$2

By:

RewriteRule ^[A-Za-z0-9]+\/weblog\/([A-Za-z0-9\.\/_-]+),?([0-9]+)?$ mod/blog/view_post.php?post=$1&commentpage=$2
 
== Step 6 - Inside mod/uri/patchs are the needed modifications to some files
who show post links. The main patch is for mod/blog/lib/weblogs_posts_view.php
If patchs fail, try apply the modifications by hand.

You can test like this:

$ cd [your_elgg_dirroot]
$ cat mod/uri/patchs/all_in_one.patch | patch -p1 --dry-run

If no errors or fail, apply the patch:

$ cat mod/uri/patchs/all_in_one.patch | patch -p1

== Step 7 - Now you can go to http://domain/elgg/weblog/everyone
and see the new fancy links ;)

You can personlize the uri as you want with some limitations, see get_uri function at mod/uri/lib.php

Keywords: friendly urls, seo, uri

Posted by Rolando Espinoza La Fuente @ Plugins


Comments

  1. thanks for the update.  I uploaded and on Step 3 when I go to the populate.php page, I get the following errors:

     


    Warning: get_uri(mod/uri/inc/uri.php) [function.get-uri]: failed to open stream: No such file or directory in /home/public_html/mod/uri/lib.php on line 47

    Warning: get_uri() [function.include]: Failed opening 'mod/uri/inc/uri.php' for inclusion (include_path='.:/usr/lib/php:/usr/local/lib/php') in /home/public_html/mod/uri/lib.php on line 47

    Fatal error: Call to undefined function: get_uri_std() in /home/public_html/mod/uri/lib.php on line 54

     

     I check the files and they are present in the directory. . .

    user iconTodd on Saturday, 02 June 2007, 15:38 UTC # |

  2. My mistake, you could download the fixed version http://elgg.org/rho/files/224/172/uri-v0.1.1a.zip

    Or add global $CFG; in mod/uri/lib.php file at line 46:

     function get_uri ($title) {
        // TODO: mainly works with $title, but should be trivial
        // work with another post attr, like tags or categories
        // or postedtime
        global $CFG;

        include_once($CFG->dirroot . 'mod/uri/inc/uri.php');

     

    user iconRolando Espinoza La Fuente on Monday, 04 June 2007, 21:27 UTC # |

You must be logged in to post a comment.

Site supported by Curverider Ltd - powered by the awesome Elgg