vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB4 Programming Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=252)
-   -   Make pretty URLs in my plugin (https://vborg.vbsupport.ru/showthread.php?t=314502)

ub.ch 09-24-2014 09:45 PM

Make pretty URLs in my plugin
 
Heya!

I want to use pretty URLs in my plugin (a marketplace) and can't seem to figure out how vBulletin does it :(

So I have something like this:

PHP Code:

/marketplace.php?do=article&id=

and would like to be

PHP Code:

/marktplatz/9-da-vinci-code 

so coming from standard PHP with URL parameters, I would like to have a german rewrite (seeing my forum is german), the article ID and the name of the article (in this case the name of the book)

So far the .htaccess is the "easy" way - if I add

PHP Code:

RewriteRule ^marktplatz/.* marketplace.php [QSA

I do see the marketplace.php (but just this one, no parameters used), but now I am sort of stuck on how to tell my plugin to use and parse the new URL structure.

Looking in members.php or other standard vBulletin pages did not seem to help and now I am asking you for any help :)

One (imho ugly) way would be to access $_SERVER['REQUEST_URI'] and parse everything to only give me the ID 9, but this seems a bit over the top.
I am sure there is another way, but I just don't know where to look

Thanks for any help!
Best
Malte

MirKO13 09-24-2014 10:31 PM

Have you tried "Mod Rewrite Friendly URLs" yet?
In Control Panel,Options, Friendly URLs....

Not sure if that's what You're looking for .
Good Luck :)

ub.ch 09-25-2014 06:48 AM

yes I have - it is turned on in my forum and it works fine.

I am more asking for the technical / code implementation.
So what are available parameters / variables so I can access 9-da-vinci-code or even better have it parsed so I have just the ID

I have found functions like fetch_seo_url(), but they don't seem to help

webmastersun 09-25-2014 01:51 PM

Enable friend url in control panel, it's enough for you to have friendly URLs on your site :)

ub.ch 09-25-2014 06:38 PM

I am not sure if I am making myself clear: I do know how to enable enable it. It is already in use. My question is, how do I as adeveloper make use of the feature in my own self coded plugin

MirKO13 09-25-2014 09:52 PM

Have You tried any SEO software yet? Like DragonByte SEO?.

Quote:

AddOn Support

Allows other modifications to add their own rewrite rules / sitemap integration

cellarius 09-26-2014 04:01 PM

Neither of the suggestions up to now will help him. He has no issues with friendly URLs in his forum. He has coded an addon, and he wants to hook that addon into the vB friendly URL system. He wants to make the URLs that his addon creates to be friendly.

I can't immediately help with the issue at hand, but more suggestions to get vB's friendly URLs running or buy expensive addons won't help him ;)

Lynne 09-26-2014 04:16 PM

Take a look at the function fetch_seo_url

https://members.vbulletin.com/api/vB...nfetch_seo_url

ub.ch 09-26-2014 04:25 PM

Quote:

Originally Posted by cellarius (Post 2516573)
Neither of the suggestions up to now will help him. He has no issues with friendly URLs in his forum. He has coded an addon, and he wants to hook that addon into the vB friendly URL system. He wants to make the URLs that his addon creates to be friendly.

I can't immediately help with the issue at hand, but more suggestions to get vB's friendly URLs running or buy expensive addons won't help him ;)

Thanks :)
I was starting to think I am not explaining myself clear enough
Quote:

Originally Posted by Lynne (Post 2516575)
Take a look at the function fetch_seo_url

https://members.vbulletin.com/api/vB...nfetch_seo_url

Thanks! But as mentioned in a post above I have already stumbled upon this function.
As far as I understand this is to generate a SEO URL but not parse an existing one :/

But I just found this thread https://vborg.vbsupport.ru/showthread.php?t=241364
(funny, earlier searches did show only good results...)

I'll read into this and keep you posted!

cellarius 09-26-2014 04:30 PM

But your problem is about generating one. You need to generate it whenever you link to pages of your addon.

Parsing does not happen in vB. That happens in .htaccess. You need an .htaccess entry that changes
Code:

/marktplatz/9-da-vinci-code
back to
Code:

/marketplace.php?do=article&id=9
Look at vB4's existing .htaccess file to get inspiration.

Edit: OK, rereading your post, you already know that and are explicitly asking for that :) But don't forget: the htaccess alone will not suffice - you also need to properly generate the URLs in vB. I am, however, not sure what a "german rewrite" exactly means...

Anyway, rewriting as you wish seems problematic, since you have two parameters in your standard URL, but only one in the friendly one.


All times are GMT. The time now is 03:04 AM.

Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.

X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.01053 seconds
  • Memory Usage 1,742KB
  • Queries Executed 10 (?)
More Information
Template Usage:
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (2)bbcode_code_printable
  • (3)bbcode_php_printable
  • (3)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (10)printthreadbit
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • showthread
Included Files:
  • ./printthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/class_bbcode_alt.php
  • ./includes/class_bbcode.php
  • ./includes/functions_bigthree.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • printthread_start
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete