Skip to:
Content
Pages
Categories
Search
Top
Bottom

Topic ID instead of slugs?


  • korobochkin
    Participant

    @korobochkin

    bbPress permalinks by default is:

    • /forums/topic/TOPIC_SLUG/
    • /forums/forum/FORUM_SLUG/

    How to replace topic- and forum- slugs to their ID’s?

    • /forums/topic/TOPIC_ID/
    • /forums/forum/FORUM_ID/

    I need this because I have cyrillic letters in topic names (and slugs).

    Current link:

    http://ru.forums.wordpress.org/topic/Пустая-страница-1?replies=3

    After copy and send on Twitter, Facebook..:

    http://ru.forums.wordpress.org/topic/

    I try fix it and write rewrite rule (and flush, yep).

    add_rewrite_rule('^/forum/topic/(\d+)/?$','index.php?topic_id=$matches[1]','top');

    But after visiting /forum/topic/814 (814 topic id is exists) redirect to home page happening.

Viewing 25 replies - 1 through 25 (of 32 total)

  • Robin W
    Moderator

    @robin-w

    Not my strong area, but I think if you reset them in

    Dashboard>settings>permalinks and change to the default that should work, or doesn’t it?


    korobochkin
    Participant

    @korobochkin

    I flush them every time after edit my plugin.

    This is my plugin — https://gist.github.com/korobochkin/d08268ce58cc65517756

    Now, this links work:

    1. /forums/forum/ID/page/2/
    2. /forums/forum/ID/
    3. /forums/forum/ID/edit/
    4. /forums/topic/ID/page/2/
    5. /forums/topic/ID/
    6. /forums/topic/ID/edit/

    But link /forums/topic/tag/tag_name/ not work. If I disable my plugin and flush rules this tag link not work too.


    korobochkin
    Participant

    @korobochkin

    In file bbpress.php I find this code:

    // Topic-View Pagination|Feed|View
    add_rewrite_rule( $view_slug . $paged_rule, 'index.php?' . $view_id . '=$matches[1]&' . $paged_id . '=$matches[2]', $priority );
    
    add_rewrite_rule( $view_slug . $feed_rule,  'index.php?' . $view_id . '=$matches[1]&' . $feed_id  . '=$matches[2]', $priority );
    
    add_rewrite_rule( $view_slug . $root_rule,  'index.php?' . $view_id . '=$matches[1]',                               $priority );

    What is it? What is feed? /forums/view/feed not open.


    korobochkin
    Participant

    @korobochkin

    Ok. I change something. Stable version :)
    https://gist.github.com/korobochkin/d08268ce58cc65517756


    Robin W
    Moderator

    @robin-w

    Thanks for posting the result :-) I’ve note the code location in case this comes up again !


    korobochkin
    Participant

    @korobochkin

    Yep. Maybe it’s time to make a first public plugin for wordpres.com?

    But question about feed is still actual. What is feed in bbPress? (see previous messages)


    Robkk
    Moderator

    @robkk

    What is feed in bbPress?

    RSS feed


    Stephen Edgar
    Moderator

    @netweb

    This is neat, thanks for sharing your code @korobochkin


    hjrhclan
    Participant

    @hjrhclan

    great!


    pooledge
    Participant

    @pooledge

    this one indeed makes its job – links are re-generated just fine!

    but unfortunately i’m getting the 404 page on click of every such link. is there any specific option to be set in permalinks section or am i missing something?

    i’ve tried to kick permalink settings to default and then back to custom with /%postname% with no luck. every time 404 is displayed i also see the path string to kolya’s plugin

    here is a working draft: http://www.pooledge.hol.es/pup4b
    forum topics are on the right sidebar in the second list

    thank you in advance for any input


    korobochkin
    Participant

    @korobochkin

    Guys. I make the repo for plugin on github, checkout the latest version with some fixes:
    https://github.com/korobochkin/bbPress-permalinks-with-id (and russian translation included).

    @pooledge don’t quite understand what you talking about. On my forum links with parameters works great with this plugin. For example:

    http://selenaselena.ru/community/talks/talk/14579/ — simply topic
    http://selenaselena.ru/community/talks/talk/14579/edit/ — edit topic, for admins only, but not 404 :)
    http://selenaselena.ru/community/talks/talk/14579/?bbp_reply_to=14806&_wpnonce=0fe9ee9c36#new-post — write reply to some user.


    korobochkin
    Participant

    @korobochkin

    BTW, issue with cyrillic links also on ru.forums.wordpress.org. And all time then I copy link I can’t send it in twitter or with message on facebook. Ok. Some browsers encode cyrilic letters:

    original:
    https://ru.forums.wordpress.org/topic/Пустая-страница-1?replies=3
    
    encoded:
    https://ru.forums.wordpress.org/topic/%D0%9D%D0%B5%D1%80%D0%B0%D0%B1%D0%BE%D1%87%D0%B8%D0%B5-%D1%81%D1%81%D1%8B%D0%BB%D0%BA%D0%B8-%D0%BD%D0%B0-ruforumswordpressorg

    but not Safari.


    pooledge
    Participant

    @pooledge

    Привет, нажми любую из тем форума на http://www.pooledge.hol.es/pup4b
    Это явно не в плагине дело, а что-то у меня


    Stephen Edgar
    Moderator

    @netweb

    Thanks for adding this to a GitHub repo, I’ll take a closer look later.

    The issue with the permalinks on ru.forums.wordpress.org is indeed known, details are here:
    https://meta.trac.wordpress.org/ticket/121

    Most likely rather than fix this in bbPress 1.x we will look to add your plugin (if needed) when we upgrade all the international forums to bbPress 2.x.


    korobochkin
    Participant

    @korobochkin

    @netweb wow you remember everything!

    @pooledge я думаю это потому что у тебя в адресе:

    /pup4b/форумы

    И мой совет, как человека, который пробовал бесплатный хостинг в Hostinger – купи нормальный хостинг за 150 рублей в месяц хотя бы и не мучайся. У них сайты вечно падают, я брал бесплатное демо ради интереса – ужаснулся.


    pooledge
    Participant

    @pooledge

    Спасибо! Жалко, что так неуниверсально.
    А хостингер – прекрасный хостинг, если за него заплатить. Бесплатный, как известно, лишь сыр.

    Regarding the 404 failure while visiting re-generated topic URLs, Kolya suggested it might be a cyrillic “mixin” like http://www.myawsomenewforum.ru/форум/topic/51156/
    Unfortunately switching all forum slugs to latin like (www.myawsomenewforum.ru/forum/topic/51156/) doesn’t do the trick, it’s still 404 for me.

    I am sorry for bothering you. Being so helpless is truly awful.


    korobochkin
    Participant

    @korobochkin

    Так а зачем ты пишешь в адресе “форум”, если хочешь с помощью моего плагина избавиться от других букв с помощью моего плагина?

    Попробуй выключить все плагины, а потом зайти на страницу /wp-admin/options-permalink.php и “Сохранить изменения”, чтобы сделать flush для ссылок на всякий случай. Должно заработать.

    У Купертино, например, 2 месяца бесплатного хостинга и работает все отлично. Хостингер постоянно падает, при попытке установить плагины вылетал и т. п. Если демо было говном, то сам продукт уже вряд ли хороший.


    Stephen Edgar
    Moderator

    @netweb

    Благодаря 😉


    pooledge
    Participant

    @pooledge

    Yes, I am sorry we kinda forgot this forum is mostly in English still 😉
    Kolya’s advice to flush permalinks while deactivating all plugins and so on combinations, .trashing and recreating .htaccess didn’t work out yet, must be something with my bbPress but I have a long autumn night going ahead which is nice..


    korobochkin
    Participant

    @korobochkin

    Oh. So without my plugin your forum work? And you use latest version from Git or not?


    pooledge
    Participant

    @pooledge

    Positive and positive. Now I’ve just made a clean install in English and set permalinks to postname. All works just fine, but right after activating the plugin all new nicely regenerated urls such as domain.com/forums/forum/11 or domain.com/forums/topic/13/ lead to 404. Unchecking forums/ prefix and flushing permalink settings doesn’t help. My wordpress installation directory is domain root, bbPress installed via plugin.

    Maybe I can help you by providing more technical details from somewhere?


    korobochkin
    Participant

    @korobochkin

    I found the bug in plugin with some validates. Never liked if ($var) constructions. if ($var !== false && $var !== '') better to understand :)

    Just replace content of plugin.php in plugin folder:
    https://github.com/korobochkin/bbPress-permalinks-with-id/blob/master/plugin/plugin.php

    Tested on brand new WordPress install only with bbPress and my plugin with default theme – works as… haha.


    pooledge
    Participant

    @pooledge

    Thank you but nope. Still no luck. See eg. http://pupyshevo.hol.es/forums/forum/11/
    Maybe some debugging? You can use my credentials on this test site, would be glad to help! Let me know and thanks again for proper support!

    Oleg

    PS: flushed permalinks with default and then with postname. Also reactivated both bbPress and the plugin. Still believe it isn’t really plugin’s fault, but me doing smth wrong…


    korobochkin
    Participant

    @korobochkin

    @pooledge Can you add me as administrator on this demo site? My email me@korobochkin.com.


    korobochkin
    Participant

    @korobochkin

    I check out your site and this f* code just not work. I see that rewrite rules from my plugin not added via add_action ('bbp_init', 'bbp_permalinks_rewrites_init', 29); hook. It’s means that:

    • Hook deleted by other plugin (hm).
    • bbp_init doesn’t exists.
    • My head is broken.

    Maybe someone get us some tips that to check or that to do.

Viewing 25 replies - 1 through 25 (of 32 total)
  • You must be logged in to reply to this topic.
Skip to toolbar