Vanilla 1 is no longer supported or maintained. If you need a copy, you can get it here.
HackerOne users: Testing against this community violates our program's Terms of Service and will result in your bounty being denied.

Friendly URLS > Customize for shorter url

edited September 2007 in Vanilla 1.0 Help
Hello, i'm working on Vanilla since a week and i just love it !
I've installed Friendly urls and I managed to have urls like /forum/1.html for discussions and /forum/1/ for categories but they're to many issues with the search function wich was not working correctly anymore...

So, i'm back to the start with the friendly urls addon.
The URLS of discussions are like : /forum/discussion/1/this-is-a-test/
I noticed that the url /forum/discussion/1/ is also working, so can someone please tell me how can i get it, and jow do i get rid of the title of the discussion in the url???

Thanks a lot,

Charles

Comments

  • edited December 2006
    ok i've found it. if someone is interrested, go to discussion.php, and replace the code line 16 by :

    <li class="DiscussionTopic"> <span>'.$this->Context->GetDefinition('DiscussionTopic').'</span><a href="'. GetUrl($Discussion->Context->Configuration, 'comments.php', '', 'DiscussionID', $Discussion->DiscussionID, $i) .'" class="DiscussionPageNumber">'.$Discussion->Name.'</a> </li>
    :-)
    This change is important to avoid google duplicate content, because with the friendly url rewrite extension (wich is great tough), the same discussions are availables with 2 differents url :
    - forum/discussion/1/
    - /forum/discussion/1/this-is-a-test/

    So as the content is of course the same, Google will consider the page is duplicate.


    PS/EDIT : Sorry for the width of the page, this is because of the code, but there's no spaces in it, by the way how to resolve this bug ?

    Bests,

    Charles
  • thanks for the info, i was also wondering how to do this :)
  • you're welcome !

    i noticed we also need to change the links of the "previous & page next" wich still contains the name of the discussion in the url.

    I guess this is managed in Framework.Class.PageList.php but i don't how to do it ;-)

    Any idea ?
  • The urls with the titles are more meaningful. Wouldn't be better to change the other ones or change the following rewrite rules:RewriteRule ^discussion/([0-9]+)/([0-9]+)/(.+)$ comments.php?DiscussionID=$1&page=$2 [QSA,L] RewriteRule ^discussion/([0-9]+)/([0-9]+)/(.+)/$ comments.php?DiscussionID=$1&page=$2 [QSA,L] RewriteRule ^discussion/([0-9]+)/(.*)$ comments.php?DiscussionID=$1 [QSA,L] RewriteRule ^discussion/([0-9]+)/(.*)/$ comments.php?DiscussionID=$1 [QSA,L]
    for ones with redirect rules:RewriteRule ^discussion/([0-9]+)/([0-9]+)/(.+)$ discussion/$1/$2/ [R=301,QSA,L] RewriteRule ^discussion/([0-9]+)/([0-9]+)/(.+)/$ discussion/$1/$2/ [R=301,QSA,L] RewriteRule ^discussion/([0-9]+)/(.*)$ discussion/$1/ [R=301,QSA,L] RewriteRule ^discussion/([0-9]+)/(.*)/$ discussion/$1/ [R=301,QSA,L]
  • well yes i could, and thank you for helping, but i'd rather get rid of titles in the urls, it's making the link deeper for no reasons as the impact of having the words in the urls is pretty limited.
    Having just the id in the url will also make simpler the writing of home made scripts like interrogating the database to retreive the last discussions, hard writtened in html (the latestpost addon is great but displayed in js).

    Do you have any idea of how i could erase the title in the "Next / Previous page" ?! :-)
    PS : sorry for my english, don't know if i made faults...hum hum
  • wow dinoboff, i didnt know u could do that with modrewrite ..... kick ass :-D
  • What does dinoboffs thing do?
  • fx35, actually, having the title in the url get's some keywords in there which can help SEO a bit. If you want to do away with them, instead think about

    http://server.com/forum/discussion/1/this-is-the-title.html

    which would be better than

    http://server.com/forum/discussion/1/
  • hello, Honnestly i don't think this is really better. Google don't like pages with urls wich are too long and with too many dashes.
    Secondly, you will have a lot of similar titles in your forum, and so will be the urls. Google could take it as duplicate content.

    And as i say, i prefer to have only IDs in he url, it makes me easier the developpment of home made scripts like displaying the last posts of the forum anywhere in my website hardcoded in html and not in js :-)

    In fact , i was looking at first to have the less deeper urls (the less deeper the better) like http://server.com/forum/1.html and i did but the search function was not working anymore ;-)))

    Well if someone now how to get rid of the titles in the links of Page Next/previous...let me know ;-)
  • @fx: I agree with the parsing issue, but full-titles in the name help not just search engines but also people.

    I just noticed that this board does what I would propose, which is use ID *and* the full title.

    Case in point:
    http://lussumo.com/community/discussion/4331/
    http://lussumo.com/community/discussion/4331/named-categories-friendly-category-links-category-slugs/

    Mark, how do you do this (which plugin?)
  • it is the normal behavior with friendly url, and that is a problem for fx35
  • Search in files ''CleanupString". Results: /library/Framework/Framework.Functions.php /library/Vanilla/Vanilla.Control.CommentGrid.php /library/Vanilla/Vanilla.Control.DiscussionForm.php /library/Vanilla/Vanilla.Functions.php /themes/discussion.php
  • Code In...

    /library/Vanilla/Vanilla.Functions.php

    String 50return GetUrl($Configuration, 'comments.php', '', 'DiscussionID', $Discussion->DiscussionID, $LastPage, '#Item_'.$JumpToItem, $Suffix);String 63return GetUrl($Configuration, 'comments.php', '', 'DiscussionID', $Discussion->DiscussionID, $PageNumber, '#Item_'.$JumpToItem, $Suffix);String 65return GetUrl($Configuration, 'comments.php', '', 'DiscussionID', $Discussion->DiscussionID, '', '', $Suffix);

    /library/Vanilla/Vanilla.Control.DiscussionForm.php

    String 129 $ResultDiscussion->DiscussionID, '', '', $Suffix);String 162$Url = GetUrl($this->Context->Configuration, 'comments.php', '', 'DiscussionID', $ResultComment->DiscussionID, $this->Discussion->LastPage, ($ResultComment->CommentID > 0 ? '#Comment_'.$ResultComment->CommentID:'#pgbottom'), $Suffix);

    ^ Delete (or comment) $Suffix and comma before. Example:
    ... /*, $Suffix*/);

    --- --- ---

    /library/Vanilla/Vanilla.Control.CommentGrid.php

    String 81$this->pl = $this->Context->ObjectFactory->NewContextObject($this->Context, 'PageList', 'DiscussionID', $this->Discussion->DiscussionID, CleanupString($this->Discussion->Name).'/');

    /themes/discussion.php (or /themes/your_theme/discussion.php)

    String 28 (Default Vanilla)<span><a href="'.GetUrl($this->Context->Configuration, 'comments.php', '', 'DiscussionID', $Discussion->DiscussionID, '', '#Item_1', CleanupString($Discussion->Name).'/').'">'.$this->Context->GetDefinition('StartedBy').'</a> </span><a href="'.GetUrl($this->Context->Configuration, 'account.php', '', 'u', $Discussion->AuthUserID).'">'.$Discussion->AuthUsername.'</a>

    ^ Delete (or comment) CleanupString($Discussion->Name) and comma before and .'/' after. Example:
    '... /*, CleanupString($Discussion->Name).'/'*/)...

    P.S. Mark, add SoftWrap to Core ;)
This discussion has been closed.