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.
Options

Req: Post # in Permalink.

edited January 2007 in Vanilla 1.0 Help
Right now it just says "permalink" I'd love to change this to "#5" (for example) so I can just say "refer to post 5" instead of forcing them to click the permalink to take them to the post in question. Seems like a simple enough edit to the existing permalink plugin (may attempt it myself).
«1

Comments

  • Options
    Figured it out, added it to the original. <?php /* Extension Name: Comments Permalinks Extension Url: http://lussumo.com/docs/ Description: Adds a "permalink" link to every comment, so you can share a single comment's url. Version: 1.0 Author: Remi Cieplicki Author Url: http://remouk.alt-tab.org/ You should cut & paste this language definition into your conf/your_language.php file (replace "your_language" with your chosen language, of course): */ $Context->Dictionary['Permalink'] = 'permalink'; function CommentGrid_Permalinks(&$CommentGrid) { global $RowNumber; $CommentList = &$CommentGrid->DelegateParameters["CommentList"]; // $CommentList .= '<a href="#Item_'. $RowNumber .'" id="Permalink_'. $RowNumber .'">' . $CommentGrid->Context->GetDefinition("Permalink").'</a>'; $CommentList .= '<a href="#Item_'. $RowNumber .'" id="Permalink_'. $RowNumber .'">#'. $RowNumber .'</a>'; $RowNumber++; } $RowNumber = 1; $Context->AddToDelegate("CommentGrid", "PostCommentOptionsRender", "CommentGrid_Permalinks"); ?>
  • Options
    This doesn't work perfectly in multi-page threads. :-/
  • Options
    Actually, another thing I'd like changed in the Permalink extension would be for it to just use the discussion ID instead of the name as well. The name sometimes changes (as it's editable) and therefor not very "perma" IMO.

    Current examples:
    http://lussumo.com/community/discussion/4867/req-post-in-permalink/#Item_1
    http://lussumo.com/community/discussion/4858/2/the-iphone-has-landed/#Item_1

    I'm suggesting that the following would be a lot more permanent:
    http://lussumo.com/community/discussion/4867/#Item_1
    http://lussumo.com/community/discussion/4858/2/#Item_1
  • Options
    The name change won't matter as it's just a "fake" addon.. for example: http://lussumo.com/community/discussion/4867/req-post-in-permalink/ is the same as this: http://lussumo.com/community/discussion/4867/hello-whee-i-rock-yay/
  • Options
    I never knew that! That's a pretty sweet capability. Thanks :D
  • Options
    There was one thing I thought of the other day, wouldn't it be better for permalink to take the post ID instead of the number on the page? So you'd get http://example.com/discussion/100/#Comment_354 rather than http://example.com/discussion/100/#Item_1 ? The problem it would solve is that you wouldn't have the whole issue with whispers and deleted comments.
  • Options
    Another thing to consider is that whispers will mess up the numbering.
  • Options
    Maybe Vanilla should change the way it labels things? After all, what happens if you change the number of comments showing per page? Would that not break the permalinks?

    Perhaps bjrn's method is better and this is really a core change? Mark, do you have an opinion on this? Is there a reason why it's not done this way?
  • Options
    edited January 2007
    Good point on the number of comments per page. Perhaps the permalink should point to only a generic CommentID and not even bother linking to its discussion.

    The extension should intercept any link pointing to a comment ID, determine which discussion it is in, which page to go to, then redirect to that. This would also be essential for the upcoming moderator tools extension, in case a comment is moved from one discussion to another.

    I.E.: http://example.com/forum/extension.php?CommentID=1234 redirects to http://example.com/forum/discussion/56/#Comment_1234
  • Options
    Yes WallPhone, I completely agree with what you just said. Can this be done without changing core, or should it be a core change?
  • Options
    For the permalink extension, I don't think you need any core changes, the #Comment_<number> is already there (do a search and click on a post's text, and you'll see it in use). There is one thing that would need a core change, when you click on a topic you get moved to the last comment, that is done with #Item_<number>, not #Comment_<number>.
  • Options
    edited January 2007
    Should be possible without a core change. Funny the difference between #Item_ and #Comment_, when you edit or create a post, your browser directed there with #Comment_... seems these are redundant. Or is the difference that yellow fade triggers when using #Comment...? I can't tell.

    testing... edit: I guess it does.
  • Options
    Looks like the page numbering only works when the discussion title is added to the URL. The second link (and the third as well) take you to page 1, not page 2.
  • Options
    StashStash
    edited January 2007
    OK then, let's try this one...

    http://lussumo.com/community/discussion/4858/2/monkeys-ate-my-grand-mother/#Comment_54906

    Well whaddaya know? It works when it's wrong :lol:
  • Options
    Hehe. Okay, that's just plain weird. I bet it's got something to do with the friendly URLs, I wonder how it works without them.
  • Options
    Unfortunately I have ZERO idea about mod_rewrite so I'm going to be no use here at all. It would be great to have this fixed though. Calling all mod_rewrite gurus!
  • Options
    I'm not a mod_rewrite guru, but doesn't it just change www.site.com/blah/etc into www.site.com/?input1=blah&input2=etc. So if there is no "input2" PHP ignores it like it always does as a variable that's submitted but never used. On the other hand, if it's www.site.com/blah/#etc then the server interprets it as &input2=#etc which is gibberish.
  • Options
    NickENickE New
    edited January 2007
    >Looks like the page numbering only works when the discussion title is added to the URL. The second link (and the third as well) take you to page 1, not page 2.
    The reason that happens, I believe, is because of the order of the mod_rewrite rules. Here's an extract from the .htaccess file:
    RewriteRule ^discussion/([0-9]+)/(.*)$ comments.php?DiscussionID=$1 [QSA,L]
    RewriteRule ^discussion/([0-9]+)/(.*)/$ comments.php?DiscussionID=$1 [QSA,L]
    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]
    You'll notice that the rules for a discussion with a title and not page are before the 'correction' rules for discussions with pages but without titles. The /(.*)/ of the second rule happens to match the page id for urls with a specified page and no title, and the page id is consequently treated like a title and 'dumped' from the url. I don't think switching them would be that great an idea, though, as titles which consist solely of numbers would then be treated as a page. Doesn't seem to be any way out of this...

    EDIT: while we're on the topic of the friendly urls extension, mark, I'd recommend enclosing all your rules/settings for mod_rewrite between
    <IfModule mod_rewrite.c>
    </IfModule>
    so that if someone's server disables mod_rewrite for some reason it will at least not cause a server error.

    And in addition, now that I think of it, you should see what aterr does to try and automatically detect if mod_rewrite is installed. In the .htaccess file, between the mod_rewrite ifmodule tags, it has the following code:
    	<IfModule mod_env.c>
    		SetEnv ATERR_REWRITE 1
    	</IfModule>
    then it tests for the environment variable ATERR_REWRITE in it's initialization code to see if the rewrite rules are in effect:
    if (false !== ($rw = getenv('ATERR_REWRITE')))
    {
    	define('REWRITE', true);
    }
    else
    {
    	define('REWRITE', $config['rewrite']);
    }
    I thought that was a pretty neat way of doing it...
  • Options
    Bugger me that's way over my head...
This discussion has been closed.