Advertisement:

Author Topic: public-profile url format  (Read 4493 times)

Sophia_OS

  • Sr. Member
  • ****
  • Posts: 416
Re: public-profile url format
« Reply #30 on: March 26, 2019, 01:14:23 am »
 This is what i need to show the public-profile!

https ://yoursite.com/cristiano-ronaldo

Web-Media

  • Sr. Member
  • ****
  • Posts: 453
  • Web
Re: public-profile url format
« Reply #31 on: March 26, 2019, 01:20:30 am »
How many users do you have ?

Sophia_OS

  • Sr. Member
  • ****
  • Posts: 416
Re: public-profile url format
« Reply #32 on: March 26, 2019, 01:45:30 am »
How many users do you have ?

Right now im working on localhost!
But for that problem i will add a string variable to the beginning of usernames!

Sophia_OS

  • Sr. Member
  • ****
  • Posts: 416
Re: public-profile url format
« Reply #33 on: March 26, 2019, 11:31:53 pm »
https ://yoursite/?cristiano
https ://yoursite/?cristiano-ronaldo/10/6
Match your needs ?

Can't you remove question mark from the url?

Sophia_OS

  • Sr. Member
  • ****
  • Posts: 416
Re: public-profile url format
« Reply #34 on: March 27, 2019, 11:59:56 am »
Hmmm you can also hook into
 osc_run_hook( 'init_user_non_secure' );  and (init_user ) hook to get the action  user id .... and redirect to a single user route.

Please explain this more!
If we redirect to single user route, we get 404.php, because there is no route for that! Right?

Sophia_OS

  • Sr. Member
  • ****
  • Posts: 416
Re: public-profile url format
« Reply #35 on: March 27, 2019, 12:02:19 pm »
You can use the main controller  to display the user profile page
Just  hook into init_main  to see if arguments in $_SERVER['REQUEST_URI'] and  display main page or user profile page if  arguments username ,items per page ,ipage
How can we redirect to a page that there is no route for that?
I guess we have to first create route for that and then redirect! Am i correct?

Web-Media

  • Sr. Member
  • ****
  • Posts: 453
  • Web
Re: public-profile url format
« Reply #36 on: March 27, 2019, 04:29:20 pm »
Yes y've told you . Using routes .
Routes takes precedence over rewrite rules .
Code: [Select]
$users=User::newInstance->listAll();
Foreach (users as user){
IF (user is active)
{Osc_add_route(user['name'],user['name']...yourpluginfile
} }
Then function
User_redirect (){
If(params::getParam(action)=='pub_profile'){
Params:getParam(username);
Params.....( ipage);
Params.... (itemsperpage)
Osc_redirect_to(osc_get_route_url(username,itemsperpage,ipage)}
}
Osc_add_hook('init_user_non_secure')...
Ask someone to build a simple plugin for you.
This works well with under 5000-10000-40000 users depends on your server hosting setup.

Web-Media

  • Sr. Member
  • ****
  • Posts: 453
  • Web
Re: public-profile url format
« Reply #37 on: March 27, 2019, 04:30:02 pm »
You can use the main controller  to display the user profile page
Just  hook into init_main  to see if arguments in $_SERVER['REQUEST_URI'] and  display main page or user profile page if  arguments username ,items per page ,ipage
How can we redirect to a page that there is no route for that?
I guess we have to first create route for that and then redirect! Am i correct?
Here there is no need for route
Just check  the existence of ? In rewrite uri
Get  username
If exist and active...
Explode on / to get extra params if exists...
If no ? Display main theme file
If ? exists display public profile pagewith params
Also the redicrect user  modified to redirect to main with parameters from above hooked into user controller
« Last Edit: March 27, 2019, 05:26:07 pm by Web-Media »

Sophia_OS

  • Sr. Member
  • ****
  • Posts: 416
Re: public-profile url format
« Reply #38 on: March 27, 2019, 08:12:48 pm »
Yes y've told you . Using routes .
Routes takes precedence over rewrite rules .
Code: [Select]
$users=User::newInstance->listAll();
Foreach (users as user){
IF (user is active)
{Osc_add_route(user['name'],user['name']...yourpluginfile
} }
Then function
User_redirect (){
If(params::getParam(action)=='pub_profile'){
Params:getParam(username);
Params.....( ipage);
Params.... (itemsperpage)
Osc_redirect_to(osc_get_route_url(username,itemsperpage,ipage)}
}
Osc_add_hook('init_user_non_secure')...
Ask someone to build a simple plugin for you.
This works well with under 5000-10000-40000 users depends on your server hosting setup.

No i don't like plugins. I'm trying to do by hook in functions.php or editing the codes.
Why do you thing that this dosnt work for users more than 40,000? Please explain this a little more!

Sophia_OS

  • Sr. Member
  • ****
  • Posts: 416
Re: public-profile url format
« Reply #39 on: March 27, 2019, 08:20:27 pm »
You can use the main controller  to display the user profile page
Just  hook into init_main  to see if arguments in $_SERVER['REQUEST_URI'] and  display main page or user profile page if  arguments username ,items per page ,ipage
How can we redirect to a page that there is no route for that?
I guess we have to first create route for that and then redirect! Am i correct?
Here there is no need for route
Just check  the existence of ? In rewrite uri
Get  username
If exist and active...
Explode on / to get extra params if exists...
If no ? Display main theme file
If ? exists display public profile pagewith params
Also the redicrect user  modified to redirect to main with parameters from above hooked into user controller

First i check the url, if its public-profile url, redirect to mysite.com/user-name. But i get 404 error!
Please write the code for this!

Web-Media

  • Sr. Member
  • ****
  • Posts: 453
  • Web
Re: public-profile url format
« Reply #40 on: March 27, 2019, 08:44:54 pm »
Do use a website like peopleperhour.com or freelancer.com
You will get good job done fast .

Web-Media

  • Sr. Member
  • ****
  • Posts: 453
  • Web
Re: public-profile url format
« Reply #41 on: March 27, 2019, 09:22:22 pm »
Meanwhile i'll build the plugin to override default rewrite class and controllers for different purposes . But that require more time .

Sophia_OS

  • Sr. Member
  • ****
  • Posts: 416
Re: public-profile url format
« Reply #42 on: March 27, 2019, 09:24:33 pm »
can we do this by: osc_add_route() ?

https://doc.osclass.org/Using_routes_in_Osclass

Web-Media

  • Sr. Member
  • ****
  • Posts: 453
  • Web
Re: public-profile url format
« Reply #43 on: March 28, 2019, 02:10:12 am »
inside a plugin yes

Sophia_OS

  • Sr. Member
  • ****
  • Posts: 416
Re: public-profile url format
« Reply #44 on: March 28, 2019, 02:20:47 am »
inside a plugin yes

Okay so lets use this function and make a plugin step by step here :D
I did alot of search to find osc_add_route() function  :)