emanuele45 / prettyurls

Automatically exported from code.google.com/p/prettyurls
Other
0 stars 0 forks source link

Tags #84

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
Add a filter for the tags mod, for textual tag URLs.

Original issue reported on code.google.com by curiousdannii on 28 Jun 2009 at 11:47

GoogleCodeExporter commented 8 years ago
I can make this but tag i should included url like
site.com/forum/tag/smf/5/

Original comment by vazgec on 28 Jun 2009 at 12:00

GoogleCodeExporter commented 8 years ago
mod:
http://mods.simplemachines.org/index.php?mod=579   
it is possible to change
tags/?tagid=1267

change
tags/sinbd
is it possible?

Original comment by arkangel...@gmail.com on 28 Jun 2009 at 9:54

GoogleCodeExporter commented 8 years ago
Arkangeles, yeah this is possible but if i make this url seems like this
http://arkangeles.org/web/foro/tags/?tagid=1252
should be
http://arkangeles.org/web/foro/tags/especial/1252/

Are you agree this ?

Original comment by vazgec on 28 Jun 2009 at 9:59

GoogleCodeExporter commented 8 years ago
is perfect

Original comment by arkangel...@gmail.com on 29 Jun 2009 at 2:43

GoogleCodeExporter commented 8 years ago
Ok. I work on this. So, I think you can have it in this weekend.  

Original comment by vazgec on 29 Jun 2009 at 3:32

GoogleCodeExporter commented 8 years ago

Original comment by vazgec on 29 Jun 2009 at 3:33

GoogleCodeExporter commented 8 years ago
Tagging callback

function pretty_tagging_filter($urls)
{
    global $scripturl, $boardurl, $modSettings, $db_prefix;

    // Do Gallery Picture Replacement
    $pattern = '`' . $scripturl . '(.*)action=tags;tagid=([0-9]+)(.*)`S';
    $query_data = array();
    foreach ($urls as $url_id => $url)
    {
        //  Get the profile data ready to query the database with
        if (!isset($url['replacement']))
            if (preg_match($pattern, $url['url'], $matches))
            {
                $urls[$url_id]['ID_TAG'] = (int) $matches[2];
                $urls[$url_id]['match1'] = $matches[1];
                $urls[$url_id]['match3'] = $matches[3];
                $query_data[] = $urls[$url_id]['ID_TAG'];
            }
    }
        if (count($query_data) != 0)
    {

    // Get the items info
        $tagids = array();
        $query = db_query("
            SELECT ID_TAG, tag
            FROM {$db_prefix}tags
            WHERE ID_TAG IN (" . implode(', ', $query_data) . ")", __FILE__, __LINE__);

while ($tagdata = mysql_fetch_assoc($query))
    $tagids[$tagdata['ID_TAG']] = $tagdata['ID_TAG'];
    mysql_free_result($query);

        // Get the items info
        $tagNames = array();
        $query = db_query("
            SELECT ID_TAG, tag
            FROM {$db_prefix}tags
            WHERE ID_TAG IN (" . implode(', ', $query_data) . ")", __FILE__, __LINE__);

while ($tagdata = mysql_fetch_assoc($query))
    $tagNames[$tagdata['ID_TAG']] = rawurlencode($tagdata['tag']);
    mysql_free_result($query);

foreach ($urls as $url_id => $url)
            if (isset($url['ID_TAG']))
                    $urls[$url_id]['replacement'] = $boardurl . '/tags/' . $tagNames[$url['ID_TAG']]
. '/' . $tagids[$url['ID_TAG']] . '/' . $url['match1'] . $url['match3'];
    }

    return $urls;
}   

Tagging filter

"Tags": {
        "description": "Tagging system for topic filter",
        "enabled": 1,
        "filter": {
            "priority": 20,
            "callback": "pretty_tagging_filter"
        },
        "rewrite": {
            "priority": 20,
            "rule": "RewriteRule ^tags/([^/]+)/([0-9]*)/?$
./index.php?action=tags;tagid=$2 [L,QSA]"
        },
        "title": "Tagging System Pretty Filter"
    }

But this codes not clean. I think Danni look at inside. 

Original comment by vazgec on 29 Jun 2009 at 4:44

GoogleCodeExporter commented 8 years ago
I forget demo url is : rockayseri.net/demo1/tags/

Original comment by vazgec on 29 Jun 2009 at 4:47

GoogleCodeExporter commented 8 years ago
where I add this code?

Original comment by arkangel...@gmail.com on 29 Jun 2009 at 8:27

GoogleCodeExporter commented 8 years ago
This code should work but we need dannii's re-action on this. Please wait dannii
reply. Because as i say, this codes not clean. 

Original comment by vazgec on 29 Jun 2009 at 9:23

GoogleCodeExporter commented 8 years ago
[deleted comment]
GoogleCodeExporter commented 8 years ago
[deleted comment]
GoogleCodeExporter commented 8 years ago
Hmm. I guess Danni not much time ATM. So you can try this ;

- go your pretty filter page (index.php?action=admin;area=pretty;sa=filters)
- Find last two "}" character. and add between this chracters

,
"Tags": {
        "description": "Tagging system for topic filter",
        "enabled": 1,
        "filter": {
            "priority": 20,
            "callback": "pretty_tagging_filter"
        },
        "rewrite": {
            "priority": 20,
            "rule": "RewriteRule ^tags/([^/]+)/([0-9]*)/?$
./index.php?action=tags;tagid=$2 [L,QSA]"
        },
        "title": "Tagging System Pretty Filter"
    }

- Open Your PrettyUrls-Filters.php
- Find ?>
- Add before

function pretty_tagging_filter($urls)
{
    global $scripturl, $boardurl, $modSettings, $db_prefix;

    // Do Gallery Picture Replacement
    $pattern = '`' . $scripturl . '(.*)action=tags;tagid=([0-9]+)(.*)`S';
    $query_data = array();
    foreach ($urls as $url_id => $url)
    {
        //  Get the profile data ready to query the database with
        if (!isset($url['replacement']))
            if (preg_match($pattern, $url['url'], $matches))
            {
                $urls[$url_id]['ID_TAG'] = (int) $matches[2];
                $urls[$url_id]['match1'] = $matches[1];
                $urls[$url_id]['match3'] = $matches[3];
                $query_data[] = $urls[$url_id]['ID_TAG'];
            }
    }
        if (count($query_data) != 0)
    {

    // Get the items info
        $tagids = array();
        $query = db_query("
            SELECT ID_TAG, tag
            FROM {$db_prefix}tags
            WHERE ID_TAG IN (" . implode(', ', $query_data) . ")", __FILE__, __LINE__);

while ($tagdata = mysql_fetch_assoc($query))
    $tagids[$tagdata['ID_TAG']] = $tagdata['ID_TAG'];
    mysql_free_result($query);

        // Get the items info
        $tagNames = array();
        $query = db_query("
            SELECT ID_TAG, tag
            FROM {$db_prefix}tags
            WHERE ID_TAG IN (" . implode(', ', $query_data) . ")", __FILE__, __LINE__);

while ($tagdata = mysql_fetch_assoc($query))
    $tagNames[$tagdata['ID_TAG']] = rawurlencode($tagdata['tag']);
    mysql_free_result($query);

foreach ($urls as $url_id => $url)
            if (isset($url['ID_TAG']))
                    $urls[$url_id]['replacement'] = $boardurl . '/tags/' . $tagNames[$url['ID_TAG']]
. '/' . $tagids[$url['ID_TAG']] . '/' . $url['match1'] . $url['match3'];
    }

    return $urls;
}   

Original comment by vazgec on 9 Jul 2009 at 11:04

GoogleCodeExporter commented 8 years ago
[deleted comment]
GoogleCodeExporter commented 8 years ago
the old url does not redirect
http://arkangeles.org/web/foro/tags/?tagid=1242

spaces do not consider
http://arkangeles.org/web/foro/tags/%20nod%2032/1317/

filter :  ( %20 )   
by
dash (-)is it possible?

Original comment by arkangel...@gmail.com on 17 Jul 2009 at 6:25

GoogleCodeExporter commented 8 years ago
Hmm.
You can remove old prettyurls-filters.php change.
And try this

function seo($sef = null){
$sef = strtolower($sef);
$degis1 = array('_',' ','--','---',' - ');
$degis2 = array('-','-','-','-','-');
$sef = str_replace($degis1,$degis2,$sef);
$sef = preg_replace("@[^A-Za-z0-9\-_]+@i","",$sef);
$sef = preg_replace(array('~^-+|-+$~', '~-+~'), array('', '-'), $sef);
return $sef;
}
function pretty_tagging_filter($urls)
{
    global $scripturl, $boardurl, $modSettings, $db_prefix;

    // Do Gallery Picture Replacement
    $pattern = '`' . $scripturl . '(.*)action=tags;tagid=([0-9]+)(.*)`S';
    $query_data = array();
    foreach ($urls as $url_id => $url)
    {
        //  Get the profile data ready to query the database with
        if (!isset($url['replacement']))
            if (preg_match($pattern, $url['url'], $matches))
            {
                $urls[$url_id]['ID_TAG'] = (int) $matches[2];
                $urls[$url_id]['match1'] = $matches[1];
                $urls[$url_id]['match3'] = $matches[3];
                $query_data[] = $urls[$url_id]['ID_TAG'];
            }
    }
        if (count($query_data) != 0)
    {

    // Get the items info
        $tagids = array();
        $query = db_query("
            SELECT ID_TAG, tag
            FROM {$db_prefix}tags
            WHERE ID_TAG IN (" . implode(', ', $query_data) . ")", __FILE__, __LINE__);

while ($tagdata = mysql_fetch_assoc($query))
    $tagids[$tagdata['ID_TAG']] = $tagdata['ID_TAG'];
    mysql_free_result($query);

        // Get the items info
        $tagNames = array();
        $query = db_query("
            SELECT ID_TAG, tag
            FROM {$db_prefix}tags
            WHERE ID_TAG IN (" . implode(', ', $query_data) . ")", __FILE__, __LINE__);

while ($tagdata = mysql_fetch_assoc($query))
    $tagNames[$tagdata['ID_TAG']] = seo($tagdata['tag']);
    mysql_free_result($query);

foreach ($urls as $url_id => $url)
            if (isset($url['ID_TAG']))
                    $urls[$url_id]['replacement'] = $boardurl . '/tags/' . $tagNames[$url['ID_TAG']]
. '/' . $tagids[$url['ID_TAG']] . '/' . $url['match1'] . $url['match3'];
    }

    return $urls;
}   

Original comment by vazgec on 17 Jul 2009 at 9:20

GoogleCodeExporter commented 8 years ago
works perfectly thank you very much ...
http://arkangeles.org/web/foro/tags/?tagid=1289
could not have a 301 redirect to
http://arkangeles.org/web/foro/tags/qlina/1289/

Original comment by arkangel...@gmail.com on 17 Jul 2009 at 8:29

GoogleCodeExporter commented 8 years ago
I don't know Php redirect systems work. And i think this is very hard on tag 
system :/

Original comment by vazgec on 17 Jul 2009 at 9:30

GoogleCodeExporter commented 8 years ago
No, don't close this topic until I've put it in the extras package.

Original comment by curiousdannii on 18 Jul 2009 at 1:38

GoogleCodeExporter commented 8 years ago
[deleted comment]
GoogleCodeExporter commented 8 years ago
Hmm. You consider that or must i make 2.0 codes for this?
And i need your opinion for this codes, maybe you say something i can make all 
other
mods filter =) Meaning Tags, simple tags, downloads, articles, smf media gallery
(actually i make it), smf gallery, Yet another global announcements etc..

Original comment by vazgec on 18 Jul 2009 at 8:23

GoogleCodeExporter commented 8 years ago
I'll most likely do this myself (especially if lots of people star this 
request), but
only after all the other 1.0 bugs are fixed.

Original comment by curiousdannii on 21 Jul 2009 at 5:27

GoogleCodeExporter commented 8 years ago
Oh, would be great for SMF Articles and SMF Downloads. Indexing by google would 
be a 
lot easier if links were like /articles/name_of_article/
I have now only like /article/id/ and /cat/id/

Would be really great!

Regards - voythas.

Original comment by voyt...@gmail.com on 25 Jul 2009 at 5:19

GoogleCodeExporter commented 8 years ago
Do Pretty URL's work with SMF EzPortal and SMF Articles ?

Original comment by abcdiamo...@gmail.com on 14 Jan 2010 at 10:54

GoogleCodeExporter commented 8 years ago
The URLs will still work but they may not be especially pretty.

Original comment by curiousdannii on 15 Jan 2010 at 4:20

GoogleCodeExporter commented 8 years ago
Thank you vazgec added your filter for pretty urls did a couple minor changes 
but
have it for SMF 1.1.x and SMF 2.0.x. Will work on the filters for download 
system,
articles, ezportal etc

Original comment by vbgame...@gmail.com on 31 Jan 2010 at 4:22

GoogleCodeExporter commented 8 years ago

Original comment by curiousdannii on 31 Jan 2010 at 8:18