Osclass forums

Development => Development => Topic started by: Sophia_OS on October 18, 2018, 08:51:30 am

Title: public-profile url format
Post by: Sophia_OS on October 18, 2018, 08:51:30 am
hey,
osclass public-profile url format is like this: website.com/profile/user-name
is there a way to make it like this? website.com/user-name
thanks
Title: Re: public-profile url format
Post by: Resta on January 03, 2019, 05:00:31 am
Once you enable the default permalinks it is not possible to do any other cursom url rewrite rules - it is all or none.
Title: Re: public-profile url format
Post by: Sophia_OS on March 22, 2019, 10:31:01 pm
Any help?
Title: .
Post by: Sophia_OS on March 23, 2019, 06:20:28 pm
.
Title: Re: public-profile url format
Post by: WEBmods on March 24, 2019, 01:20:46 am
Short: NOT possible

Little longer: Maybe with heavy modifications to /oc-includes/osclass/classes/Rewrite.php (https://github.com/osclass/Osclass/blob/master/oc-includes/osclass/classes/Rewrite.php)...

Regards.
Title: Re: public-profile url format
Post by: Sophia_OS on March 24, 2019, 06:25:07 am
Short: NOT possible

Little longer: Maybe with heavy modifications to /oc-includes/osclass/classes/Rewrite.php (https://github.com/osclass/Osclass/blob/master/oc-includes/osclass/classes/Rewrite.php)...

Regards.

@Patrick
Here we could easily make items like this: website.com/item7566
Dashboard → Settings → Permalinks → Listing URL: item{ITEM_ID}

Why and what is the reason that osclass didn't give us that option for public-profile URL?

Thank you for addressing me the Rewrite.php file. Let me work a little on this file and see if we could make this happen.
Thanks
Title: Re: public-profile url format
Post by: Sophia_OS on March 24, 2019, 08:39:08 pm
i tried and could not solve this by Rewrite.php file.
can we do this by htaccess file?
Title: Re: public-profile url format
Post by: Web-Media on March 25, 2019, 04:23:03 pm
Short answer .. yes you can by adding routes . But that depends on the number of users .  More users harder  and slower to match . Www.yoursite/london  it is a user called london a category called london  ot a city called london ?  You have to make sure that your user names do not match either cities in your database or category name . Thats the short version . The long version will take some hours to write the answer and weeks to think and  implement a new router inside  some routes
Title: Re: public-profile url format
Post by: WEBmods on March 25, 2019, 06:13:52 pm
And I guess that if you make a route you need to change url from original to route in all core files?
Title: Re: public-profile url format
Post by: Web-Media on March 25, 2019, 08:30:38 pm
No need to change core files . Just add username as route name . But like ive said .. implementint a username strategy on user register or edit username  not allow names that already exist as city region or categoryY've made some tests with  works well  under 10 000 routes . Matching  the route under 0.1 sec . With 512 mb ram.. shared hosting...  But if the number of routes increases ,more memory is needed more time will be consumed ,and some changes to rewrite class to match faster . Now it used foreach  routes as route {preg match  }  . You will have to implement a diferent strategy with static routes .
Title: Re: public-profile url format
Post by: Sophia_OS on March 25, 2019, 08:39:22 pm
Short answer .. yes you can by adding routes . But that depends on the number of users .  More users harder  and slower to match . Www.yoursite/london  it is a user called london a category called london  ot a city called london ?  You have to make sure that your user names do not match either cities in your database or category name . Thats the short version . The long version will take some hours to write the answer and weeks to think and  implement a new router inside  some routes

@Web-Media
That's an easy fix. We could add a variable at the beginning of user-name.
$users = 'user-'
$users{USER-NAME}
And we never get that kind of problems.

Please help us to do by adding routes!
Thanks,
Title: Re: public-profile url format
Post by: Sophia_OS on March 25, 2019, 08:48:42 pm
No need to change core files . Just add username as route name . But like ive said .. implementint a username strategy on user register or edit username  not allow names that already exist as city region or categoryY've made some tests with  works well  under 10 000 routes . Matching  the route under 0.1 sec . With 512 mb ram.. shared hosting...  But if the number of routes increases ,more memory is needed more time will be consumed ,and some changes to rewrite class to match faster . Now it used foreach  routes as route {preg match  }  . You will have to implement a diferent strategy with static routes .

When a user registers, by default user-name is user-id. And after that if we disable user-name changes for users, problem will be solved. Or as i explained above we could add a varibale at the beginning of user-name.
Title: Re: public-profile url format
Post by: Web-Media on March 25, 2019, 08:50:49 pm
And what is the diference between
Yoursite.com/profile/cristiano-ronaldo
And
Yoursite.com/user-cristiano-ronaldo
?
Title: Re: public-profile url format
Post by: Web-Media on March 25, 2019, 08:58:24 pm
Or you can create a single route as new entry point of your website and  you've just create a new index controller .
From there you can define  a new url matching  for items categories regions cities and users  and use an external library as your main router.
Title: Re: public-profile url format
Post by: Sophia_OS on March 25, 2019, 09:00:02 pm
And what is the diference between
Yoursite.com/profile/cristiano-ronaldo
And
Yoursite.com/user-cristiano-ronaldo
?

What is the difference between these two?

example.blogspot.com
and
example.blog.blogspot.com

The difference is to make it easy for users!
Title: Re: public-profile url format
Post by: Sophia_OS on March 25, 2019, 09:07:38 pm
Or you can create a single route as new entry point of your website and  you've just create a new index controller .
From there you can define  a new url matching  for items categories regions cities and users  and use an external library as your main router.

This is really hard for me to write the code  :-\
Title: Re: public-profile url format
Post by: Web-Media on March 25, 2019, 09:22:43 pm
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.
Title: Re: public-profile url format
Post by: Sophia_OS on March 25, 2019, 09:29:50 pm
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.
:-[ would you please write the code example!
Title: Re: public-profile url format
Post by: Sophia_OS on March 25, 2019, 09:39:39 pm
I found this page in google!

https://stackoverflow.com/questions/30237861/in-osclass-change-http-domainname-user-profile-1-to-http-domainname-username
Title: Re: public-profile url format
Post by: Web-Media on March 25, 2019, 09:59:15 pm
Change in the db rewrite_user_profile to users and you ll get
Yoursite /users/messi
Title: Re: public-profile url format
Post by: Sophia_OS on March 25, 2019, 10:09:59 pm
Change in the db rewrite_user_profile to users and you ll get
Yoursite /users/messi

Yes your right. That doesn't solve the problem!
Title: Re: public-profile url format
Post by: Web-Media on March 25, 2019, 10:36:38 pm
And you will get another problem
How about
Yoursite.com/cristiano-ronaldo/videos
Yoursite.com/cristiano-ronaldo/videos/2
Yoursite.com/cristiano-ronaldo/videos/2/asc
Yoursite.com/cristiano-ronaldo/news ....
Keeping the
https://demo.osclass.org/general/user/profile/cristiano?iPage=2
Is the best options
Because you keep options for further plugins for users
Like
https://demo.osclass.org/general/user/videos/cristiano?iPage=2
https://demo.osclass.org/general/videos/cristiano/Page=2
https://demo.osclass.org/general/user/news/cristiano?iPage=2
Title: Re: public-profile url format
Post by: Web-Media on March 26, 2019, 12:24:09 am
https://demo.osclass.org/general/?cristiano
https://demo.osclass.org/general/?cristiano-ronaldo/10/6
Match your needs ?
Title: Re: public-profile url format
Post by: Web-Media on March 26, 2019, 12:30:32 am
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
Title: Re: public-profile url format
Post by: Sophia_OS on March 26, 2019, 12:51:14 am
And you will get another problem
How about
Yoursite.com/cristiano-ronaldo/videos
Yoursite.com/cristiano-ronaldo/videos/2
Yoursite.com/cristiano-ronaldo/videos/2/asc
Yoursite.com/cristiano-ronaldo/news ....
Keeping the
https://demo.osclass.org/general/user/profile/cristiano?iPage=2
Is the best options
Because you keep options for further plugins for users
Like
https://demo.osclass.org/general/user/videos/cristiano?iPage=2
https://demo.osclass.org/general/videos/cristiano/Page=2
https://demo.osclass.org/general/user/news/cristiano?iPage=2

I have only one category.
And here for user profile i just put (profile)
Dashboard → Settings → Permalinks → User profile: profile
Now my public-profile format is: mysite.com/profile/user-name
And im trying to remove "profile" from the url to be: mysite.com/user-name
Title: Re: public-profile url format
Post by: Web-Media on March 26, 2019, 12:53:11 am
https ://yoursite/?cristiano
https ://yoursite/?cristiano-ronaldo/10/6
Match your needs ?
Title: Re: public-profile url format
Post by: Sophia_OS on March 26, 2019, 12:53:55 am
https://demo.osclass.org/general/?cristiano
https://demo.osclass.org/general/?cristiano-ronaldo/10/6
Match your needs ?

I don't want category name to show in public-profile.
Title: Re: public-profile url format
Post by: Web-Media on March 26, 2019, 12:56:20 am
there is no category name its just osclass demo setup https://demo.osclass.org/jobboard/
we are talking about this
https ://yoursite/?cristiano
https ://yoursite/?cristiano-ronaldo/10/6
Title: Re: public-profile url format
Post by: Sophia_OS on March 26, 2019, 12:56:30 am
https ://yoursite/?cristiano
https ://yoursite/?cristiano-ronaldo/10/6
Match your needs ?

Would you please remove "?" From the url!
Title: Re: public-profile url format
Post by: Sophia_OS on March 26, 2019, 12:58:50 am
there is no category name its just osclass demo setup https://demo.osclass.org/jobboard/
we are talking about this
https ://yoursite/?cristiano
https ://yoursite/?cristiano-ronaldo/10/6

Got you! This is good if you remove "?" from the url!
Title: Re: public-profile url format
Post by: Sophia_OS on March 26, 2019, 01:14:23 am
 This is what i need to show the public-profile!

https ://yoursite.com/cristiano-ronaldo
Title: Re: public-profile url format
Post by: Web-Media on March 26, 2019, 01:20:30 am
How many users do you have ?
Title: Re: public-profile url format
Post by: Sophia_OS 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!
Title: Re: public-profile url format
Post by: Sophia_OS 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?
Title: Re: public-profile url format
Post by: Sophia_OS 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?
Title: Re: public-profile url format
Post by: Sophia_OS 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?
Title: Re: public-profile url format
Post by: Web-Media 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.
Title: Re: public-profile url format
Post by: Web-Media 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
Title: Re: public-profile url format
Post by: Sophia_OS 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!
Title: Re: public-profile url format
Post by: Sophia_OS 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!
Title: Re: public-profile url format
Post by: Web-Media 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 .
Title: Re: public-profile url format
Post by: Web-Media 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 .
Title: Re: public-profile url format
Post by: Sophia_OS on March 27, 2019, 09:24:33 pm
can we do this by: osc_add_route() ?

https://doc.osclass.org/Using_routes_in_Osclass
Title: Re: public-profile url format
Post by: Web-Media on March 28, 2019, 02:10:12 am
inside a plugin yes
Title: Re: public-profile url format
Post by: Sophia_OS 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  :)
Title: Re: public-profile url format
Post by: Sophia_OS on March 28, 2019, 08:43:17 am
We change this url:

With permalink: mysite.com/profile/user-name1
Without permalink: mysite.com/index.php?page=user&action=pub_profile&id=1

To this:

mysite.com/user-name1


What values should i put for arguments in this function:
osc_add_route($id, $regexp, $url, $file)
Title: Re: public-profile url format
Post by: Web-Media on March 28, 2019, 10:19:36 am
https://github.com/osclass/plugin-routes_example
Where did you get the idea of yoursite.com/user-cristiano1 ?
You will nedd a separator between name /itemsperpage/page
You are on dinamic routes
Title: Re: public-profile url format
Post by: Web-Media on March 28, 2019, 10:50:16 am
Your options are
Using rewrite
Site.com/users/cristiano?ipp=10&page=2
Using routes
Site.com/cristiano/10/2
Or site.com/user-cristiano/10/2
Using main controller
Site.com/?cristiano/10/2
Title: Re: public-profile url format
Post by: Web-Media on March 28, 2019, 10:55:19 am
osc_add_route($user[s'username], $user[s'username]/([0-9]+)/([0-9]+)', '$user[s'username]/{my-numeric-param}/{my-own-param}',
Check the db field name .. $user['s_username]...im on mobile
Title: Re: public-profile url format
Post by: Sophia_OS on March 28, 2019, 07:23:40 pm
osc_add_route($user[s'username], $user[s'username]/([0-9]+)/([0-9]+)', '$user[s'username]/{my-numeric-param}/{my-own-param}',
Check the db field name .. $user['s_username]...im on mobile

But i don't want :
site.com/user-cristiano/10/2

I want:
site.com/user-cristiano
Title: Re: public-profile url format
Post by: Web-Media on March 28, 2019, 08:15:39 pm
Hope you are kidding . And how do you display page 2 , page 5
 How do you know how many items per page .
Y did laugh at your joke  :) ;D
Title: Re: public-profile url format
Post by: Sophia_OS on March 28, 2019, 11:36:16 pm
Hope you are kidding . And how do you display page 2 , page 5
 How do you know how many items per page .
Y did laugh at your joke  :) ;D

i'm so sorry  :) i thought that's the public-profile main url! but that's the pages for user's items! sorry!

now for making site.com/user-cristiano we should do this? right?
osc_add_route($user[s'username], $user[s'username]/([0-9]+)/([0-9]+)', '$user[s'username]/{my-numeric-param}/{my-own-param}');
Title: Re: public-profile url format
Post by: Web-Media on March 29, 2019, 12:55:01 am
osc_add_route($user['s_username'], 'user-'.$user['s_username']/([0-9]+)/([0-9]+)', 'user-'.$user['s_username']/{my-numeric-param}/{my-own-param}','yourplugin_file .php',false,'custom','custom','Profile page of'.$user['s_username']);
Title: Re: public-profile url format
Post by: Sophia_OS on March 29, 2019, 03:16:21 am
osc_add_route($user['s_username'], 'user-'.$user['s_username']/([0-9]+)/([0-9]+)', 'user-'.$user['s_username']/{my-numeric-param}/{my-own-param}','yourplugin_file .php',false,'custom','custom','Profile page of'.$user['s_username']);

What should we put for these:
{my-numeric-param}
{my-own-param}
Title: Re: public-profile url format
Post by: Sophia_OS on March 29, 2019, 06:28:30 am
Other users please don't just watch, leave your comments and cooperate to solve this topic! Thanks!
Title: Re: public-profile url format
Post by: Web-Media on March 29, 2019, 09:26:58 am
Use descriptive param name .. like ipp page . Any words will do the job .
Use the same  for reverse routing on
osc_route_url....
Y will build you the plugin this week end .
Title: Re: public-profile url format
Post by: Sophia_OS on March 29, 2019, 09:41:08 am
Use descriptive param name .. like ipp page . Any words will do the job .
Use the same  for reverse routing on
osc_route_url....
Y will build you the plugin this week end .

Thank you!
Title: Re: public-profile url format
Post by: Resta on March 30, 2019, 01:16:45 am
Other users please don't just watch, leave your comments and cooperate to solve this topic! Thanks!
Good advice - you should do the same and "may be I am wrong" when I say this but for the time I have been a member here, I have not come across any threads where you have responded to someone else looking for help or contributed to any other topics, other than those topics where you are looking for solution to your own issues and I think you have more knowledge about osclass than many new users here, whom you can help.
Title: Re: public-profile url format
Post by: Web-Media on March 31, 2019, 06:16:35 pm
Done 98 % . Some small issues with pagination , but works well .
 I,ve saved a lot of memory usage by adding 1 single route , not all users in database  ;)
No changes in core osclass files .
No changes in theme files.
Yoursite.com /user-cris is available
 also with pagination
Yoursite.com /user-cris/10/2
Title: Re: public-profile url format
Post by: Sophia_OS on April 01, 2019, 03:23:47 am
Done 98 % . Some small issues with pagination , but works well .
 I,ve saved a lot of memory usage by adding 1 single route , not all users in database  ;)
No changes in core osclass files .
No changes in theme files.
Yoursite.com /user-cris is available
 also with pagination
Yoursite.com /user-cris/10/2

Well done! Would you please share the code with us!
Title: Re: public-profile url format
Post by: Web-Media on April 01, 2019, 09:02:26 am
Sure. When ready 100%  and tested ill upload to github
Title: Re: public-profile url format
Post by: Sophia_OS on April 01, 2019, 09:39:37 am
How long does it take?  :)
Please also give an option to be able to put a variable at the beginning of user-name!
$var = "user-";
Yoursite.com/$var"user-cris"
Thank you very very much!
Title: Re: public-profile url format
Post by: Web-Media on April 01, 2019, 04:03:39 pm
Sounds better :
Yoursite.com/$var"-cris"
Where  var can be user or any string(word)
Yoursite.com/user-cris
Title: Re: public-profile url format
Post by: Sophia_OS on April 01, 2019, 08:41:30 pm
Sounds better :
Yoursite.com/$var"-cris"
Where  var can be user or any string(word)
Yoursite.com/user-cris

Yes! Please make both work!
Default be just user-name. But put an option we could also be able to add $var at the beginning of user-name.
Yoursite.com/cris //default!
Yoursite.com/$var"cris" //option to add variable!
Title: Re: public-profile url format
Post by: Sophia_OS on April 02, 2019, 08:37:42 pm
@Web-Media,
Did you finish the code?
Title: Re: public-profile url format
Post by: Web-Media on April 02, 2019, 09:17:18 pm
Sorry . Not yet . Y do not have a lot of spare time
Title: Re: public-profile url format
Post by: Web-Media on April 02, 2019, 09:43:50 pm
Question : whitch page  do you wanna redirect if   user does not exist , is not active, or blocked ?
 i'll put main page and search page as options
Title: Re: public-profile url format
Post by: Sophia_OS on April 03, 2019, 12:43:44 am
Question : whitch page  do you wanna redirect if   user does not exist , is not active, or blocked ?
 i'll put main page and search page as options
Main page is good!
Title: Re: public-profile url format
Post by: Sophia_OS on April 08, 2019, 11:14:53 am
@Web-Media,
Any update?
Title: Re: public-profile url format
Post by: Web-Media on April 08, 2019, 12:47:43 pm
Plugin is done .. pagination works well .
Yoursite .com/$variable-{username}
Yoursite .com/$variable-{username}/2 ... (pagination)
Yoursite .com/$variable-{username}/7/3  ( itemsperpage/page)
Is user is not enabled or active  go to (search or main ) admin choise
If user do not exist .. go to search or main .
No changes to core or theme files
Just some finishing touches and to setup a domain demo and upload the free plugin
Title: Re: public-profile url format
Post by: Sophia_OS on April 08, 2019, 09:38:35 pm
Thank you very much!
Title: Re: public-profile url format
Post by: Sophia_OS on April 09, 2019, 10:43:00 am
Thanks
Title: Re: public-profile url format
Post by: Web-Media on April 09, 2019, 12:19:26 pm
Today  at 21 -22 i'll send you the plugin
Title: Re: public-profile url format
Post by: Sophia_OS on April 09, 2019, 01:12:34 pm
Thanks!
Title: Re: public-profile url format
Post by: Web-Media on April 09, 2019, 10:42:40 pm
You have it . Few more test .. and available for free on github
Title: Re: public-profile url format
Post by: Sophia_OS on April 10, 2019, 12:02:07 am
@Web-Media Thank you very much!
Title: Re: public-profile url format
Post by: Sophia_OS on April 12, 2019, 12:44:02 am
@Web-Media
Please help me to remove the "user-"
Thanks
Title: Re: public-profile url format
Post by: Sophia_OS on April 12, 2019, 10:47:52 am
@Web-Media,

how can i check the public-profile without user- ?
Title: Re: public-profile url format
Post by: Web-Media on April 12, 2019, 12:56:01 pm
Don't alter the code i've sent you .
You are trying to achieve big things with simple logic and code lines .
This doesnt work like that .
Without 'user-' there is a different code logic begining with user registration ,user edit and so on .
You have to implement a complete strategy of url rewrite for all posible links
Yoursite/barcelona -> means barcelona is a region or a static page or a user
Yoursite/barcelona/barcelona -> region city
Yoursite/london -> possible user called london
If user is  your main interest other links cannot be used
You cannot rewrite all osclass code with a simple question like can you help me ?
First draw the big picture for your website and try to achieve it with simple steps taking into consideration the other steps you have to make .
In programming it is called DRY. Don't repeat yourself .
So building a plugin for urlrewrite yoursite/cristiano have to be script wide and to take into consideration all links combination for your website.
Y'll build this but takes time . Be patient.
Title: Re: public-profile url format
Post by: Sophia_OS on April 12, 2019, 09:11:09 pm
@Web-Media
But if you remember i had asked you yoursite.com/username and if its possible put $var as an option not as requirement.
Please put an option on plugin to remove (user-) or tell me how to do it!
Thank you!
Title: Re: public-profile url format
Post by: Web-Media on April 12, 2019, 11:03:05 pm
Short answer .. yes you can by adding routes . But that depends on the number of users .  More users harder  and slower to match . Www.yoursite/london  it is a user called london a category called london  ot a city called london ?  You have to make sure that your user names do not match either cities in your database or category name . Thats the short version . The long version will take some hours to write the answer and weeks to think and  implement a new router inside  some routes
   that i've said 2 week ago .
 Do it yourself .  On user registration and user edit check that do not match region,city,category or page or any existent routes . Add routes with usernames
Title: Re: public-profile url format
Post by: Sophia_OS on April 12, 2019, 11:55:16 pm
@Web-Media
Yes i can check on username registration that checks all pages and locations before giving the username! Thanks you!
Now please explain more about adding routes with username! How can i start?
Title: Re: public-profile url format
Post by: Sophia_OS on April 15, 2019, 09:03:42 pm
@Web_media
on localhost it works very good,
but on server it doesn't work, why? it successfully redirects to Yoursite.com/user-cris but shows the content of 404 page! why?
Title: Re: public-profile url format
Post by: Web-Media on April 15, 2019, 09:09:29 pm
Any errors on debug log ?
I'll check in my server setup
Title: Re: public-profile url format
Post by: Sophia_OS on April 15, 2019, 09:39:54 pm
Any errors on debug log ?
I'll check in my server setup

i put this code in config file, but did not see any error!
define('OSC_DEBUG', true) ;
Title: Re: public-profile url format
Post by: Sophia_OS on April 16, 2019, 06:45:50 am
Did you find the issue?
Title: Re: public-profile url format
Post by: Sophia_OS on April 17, 2019, 01:49:05 am
@Web_media
Did you check it?
Title: Re: public-profile url format
Post by: Web-Media on April 17, 2019, 10:51:01 pm
Did you change the variable from admin setings ?
Title: Re: public-profile url format
Post by: Sophia_OS on April 17, 2019, 10:58:15 pm
Did you change the variable from admin setings ?

Yes i changed it!
Title: Re: public-profile url format
Post by: Sophia_OS on April 17, 2019, 11:26:11 pm
i changed it to "user", but still not working!
Title: Re: public-profile url format
Post by: Web-Media on April 18, 2019, 12:14:30 am
https://forums.osclass.org/development/user-profile-url/  it is public now .
lets  see if someone  could help debugging
Title: Re: public-profile url format
Post by: Web-Media on April 18, 2019, 12:29:29 am
The problem must be in the sethpath plugin router . I'll look into it
Title: Re: public-profile url format
Post by: Web-Media on April 18, 2019, 01:57:15 am
check your htacces file
Code: [Select]
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]

</IfModule>
Title: Re: public-profile url format
Post by: Sophia_OS on April 18, 2019, 04:47:32 am
check your htacces file
Code: [Select]
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]

</IfModule>

htaccess file is correct!
please check the paths
Title: Re: public-profile url format
Post by: Web-Media on April 18, 2019, 09:04:39 am
I've had same issue .Didn't get the theme file 404 but server 404.  Activating the permalinks somehow doesnt write the  htacces file. I've had to edit  htacces  myself .
Title: Re: public-profile url format
Post by: Sophia_OS on April 18, 2019, 09:51:23 am
I've had same issue .Didn't get the theme file 404 but server 404.  Activating the permalinks somehow doesnt write the  htacces file. I've had to edit  htacces  myself .

If the problem is htaccess, then why its working on localhost? Because localhost has the same htaccess!
Title: Re: public-profile url format
Post by: Web-Media on April 18, 2019, 10:24:49 am
It's about rewrite base and public_html folder
Title: Re: public-profile url format
Post by: Sophia_OS on April 18, 2019, 10:38:50 am
It's about rewrite base and public_html folder

So why osclass's own routes work good with this htaccess and have no problem with public_html folder?
Title: Re: public-profile url format
Post by: Web-Media on April 18, 2019, 11:03:56 am
Cannot dive deeper  into this htacces .
Had same issue .
Enabling permalinks didn't work for whole site becouse htaccea wasnt updated  by osclass . .. seever issue .. script issue .. i dont know.
 Solved editing htacces  by hand
http://oscmad.com/kb-cris
Plugin  works fine
Title: Re: public-profile url format
Post by: Sophia_OS on April 18, 2019, 11:10:14 am
Please share with us your htaccess file! Thanks!
Title: Re: public-profile url format
Post by: Web-Media on April 18, 2019, 11:16:56 am
I just did  before .
Title: Re: public-profile url format
Post by: Sophia_OS on April 18, 2019, 11:48:02 am
I just did  before .

Not plugin! Htaccess file! You solved the issue by editing the htaccess file right?
Title: Re: public-profile url format
Post by: Web-Media on April 18, 2019, 12:08:11 pm
Yes . Htacces 
Title: Re: public-profile url format
Post by: Sophia_OS on April 18, 2019, 12:36:31 pm
Yes . Htacces

Please give us your htaccess file! Thanks
Title: Re: public-profile url format
Post by: Sophia_OS on April 18, 2019, 12:40:50 pm
This is my htaccess:
Would you please edit this to work?
Thanks,

Code: [Select]
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
Title: Re: public-profile url format
Post by: Web-Media on April 18, 2019, 02:12:25 pm
Exactly like my htacces . Now . Enable permalinks . See if works for whole website .  See if plugin works . Then disable permalinks .. see if plugin works again ..
Let see if others has same issue .

Your domain is the main domain or addon domain ?
Your osclass is inside public_html folder ?
Title: Re: public-profile url format
Post by: Sophia_OS on April 18, 2019, 11:54:04 pm
Exactly like my htacces . Now . Enable permalinks . See if works for whole website .  See if plugin works . Then disable permalinks .. see if plugin works again ..
Let see if others has same issue .

Your domain is the main domain or addon domain ?
Your osclass is inside public_html folder ?

Not working! with Permalinks or without Permalinks!
with Permalinks = it redirects to yoursite.com/user-cris but shows 404.php content!
without Permalinks = it also redirects to yoursite.com/user-cris but shows main.php content!

- domain is main-domain
- i even replaced all the PLUGINS_PATH in index.php with (Path-to-your-Web-document-root + oc-content/plugins/) provided by host, but did the same error again! nothing changed!
- without user_profile plugin, whole website works great with or without Permalinks!
Title: Re: public-profile url format
Post by: Web-Media on April 19, 2019, 06:08:51 pm
Did the user cris exist ?
Is user enabled  and active ?
Did you setup the redirect  to go to main page when username does not exist  or is not active ?
 404 from theme file or server 404 default page  ?
Title: Re: public-profile url format
Post by: Sophia_OS on April 19, 2019, 10:03:10 pm
Did the user cris exist ?
Is user enabled  and active ?
Did you setup the redirect  to go to main page when username does not exist  or is not active ?
 404 from theme file or server 404 default page  ?
Did the user cris exist ? Yes
Is user enabled  and active ? Yes
Did you setup the redirect  to go to main page when username does not exist  or is not active ? No difference. I even changed to go to search.php but with Permalinks it shows the 404.php content and without Permalinks it shows main.php content! (But urls are not main.php or 404.php)
404 from theme file or server 404 default page  ? It dosnt show the 404.php in url, it just shows the content of 404.php in bender theme! Because i put a echo 'i am 404 in bender'; and it showed me that! (When i removed the 404.php in bender theme it showed the white page with the message: Not Found, Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request.) This was when Permalinks On, whwn Permalinks is off always shows the main.php content no matter i choose main or search in plugin setting!
Title: Re: public-profile url format
Post by: Sophia_OS on April 25, 2019, 12:46:01 pm
Please someone tells us why @Web_media's plugin works great on localhost but NOT on server! Thanks,

https://github.com/web-media/user_profile
Title: Re: public-profile url format
Post by: Sophia_OS on April 26, 2019, 09:32:14 am
@Web-Media
Did you fix that issue?
Thanks
Title: Re: public-profile url format
Post by: Sophia_OS on May 02, 2019, 11:34:31 am
Really? In this forum no one knows why this plugin works on localhost but not on server?
If you don't wanna fix it, at least tell me the reason that this plugin dosnt work on the server!
I changed all the plugin path with server path but didn't work!
What could be that there is on localhost and not on server to prevent working?
Please leave your comments
Thanks
Title: Re: public-profile url format
Post by: Sophia_OS on May 04, 2019, 03:48:03 am
Please someone tests this plugin on server and let us know that works or not! Thanks!
Title: Re: public-profile url format
Post by: Sophia_OS on May 04, 2019, 05:57:05 am
@Web-Media
I found the issue!
i analyzed the plugin, user_profile_custom() function doesn't work on the server! why?
Title: Re: public-profile url format
Post by: Sophia_OS on May 08, 2019, 05:12:12 am
Please one of the osclass Admins test this plugin on the server and confirm that doesn't work!
For me on localhost works, but on the server doesn't! And I'm trying to find out why!
Thanks

https://github.com/web-media/user_profile
Title: Re: public-profile url format
Post by: Web-Media on May 08, 2019, 09:18:26 am
I'll look into  it  folowing days  and rewrite the code with some custom exit  statuses to identify the problem faster .
Title: Re: public-profile url format
Post by: Sophia_OS on May 08, 2019, 10:44:46 am
I'll look into  it  folowing days  and rewrite the code with some custom exit  statuses to identify the problem faster .

Thank you,
Just let you know that i analyzed the plugin and in index.php, function user_profile_custom() doesn't work on server! The reason is init_custom hook doesn't work on the server.
I'm waiting for your reply
Thanks
Title: Re: public-profile url format
Post by: Web-Media on May 08, 2019, 12:47:31 pm
There is  2 ways to land to user profile page .
Typing the url yoursite /var-username .. etc
Or cliking on user link on various parts of the website  and plugin redirect to custom page route .
Try accesing both to see if any methods has errors
Actually i've forgot to comment one line in the code index .php line 117
Code: [Select]
osc_add_route('cris', 'cris', 'cris' , osc_plugin_folder('user_profile/index.php') . 'views/cris.php', false, 'custom', 'pub_profile', __('Profile Page Of ') );

so if you have a user named cris there will be an error
Title: Re: public-profile url format
Post by: Sophia_OS on May 08, 2019, 08:06:23 pm
@Web-Media
1. There is no "cris" username on my website! That was just example!
2. On the server when i click or type public-profile of any user, it redirects to mysite.com/var-username but content of page is error404. That means it redirects to new url but website dosnt recognize that url! Its like you type a random word at the end of your website: mysite.com/thshdjfbeg and get error!
3. On the server, index.php, user_profile_redirect() function works good, that's why it redirects to new url.
But user_profile_custom() dosnt work, that's why it dosnt route the new url to public-profile. When i change the init_custom hook with before_html hook, function works but inside of the function $route variable gets empty!
4. Please just analize index.php -> function user_profile_custom() on the server. The problem is just this function.
Thank you!
Title: Re: public-profile url format
Post by: Sophia_OS on May 10, 2019, 06:00:41 am
@Web-Media
Any update?
Title: Re: public-profile url format
Post by: Web-Media on May 10, 2019, 11:02:22 pm
let see  if works .. in index. php a bout line 134
Code: [Select]
$basePath = rtrim($pathinfo['dirname'],'/');

            $router = new \AltoRouter();
           
            $router->setBasePath($basePath);
  look for it and replace with the code above
Title: Re: public-profile url format
Post by: Sophia_OS on May 11, 2019, 06:48:10 am
@Web-Media
Thank you very much! finally you fixed it  :)
now first bug fixed! let's fix the second bug!
second bug:
some browsers, etc, automatically put '/' at the end of url!
when you put '/' at the end of user-name, it gives 404 error!
ex. Yoursite.com/var-username/
Thanks,
Title: Re: public-profile url format
Post by: Web-Media on May 11, 2019, 10:39:39 am
In your htacces
After
RewriteCond %{REQUEST_FILENAME} !-d
Add
RewriteRule ^/(.*)/$ /$1 [R=301,L]
Title: Re: public-profile url format
Post by: Sophia_OS on May 11, 2019, 12:41:16 pm
In your htacces
After
RewriteCond %{REQUEST_FILENAME} !-d
Add
RewriteRule ^/(.*)/$ /$1 [R=301,L]

did NOT work,
and also all my CSS did NOT work!
Title: Re: public-profile url format
Post by: Web-Media on May 11, 2019, 01:02:07 pm
Thats server  config ..
Try google "remove trailing slash apache"
Title: Re: public-profile url format
Post by: Sophia_OS on May 11, 2019, 02:29:53 pm
Thats server  config ..
Try google "remove trailing slash apache"

but all of the website pages works with "/" except public-profile!
this is a plugin issue! because without plugin it works great!

somewhere in plugin, it checks the route or uri and doesn't accept "/"
please find that part of the code and remove "/" with str_replace
Title: Re: public-profile url format
Post by: Web-Media on May 11, 2019, 02:59:54 pm
Ill look into it
Title: Re: public-profile url format
Post by: Sophia_OS on May 11, 2019, 03:18:07 pm
Thanks
Title: Re: public-profile url format
Post by: Sophia_OS on May 13, 2019, 01:29:03 pm
@Web-Media
Any update?
Title: Re: public-profile url format
Post by: Web-Media on May 16, 2019, 01:04:46 am
classes /router.php
line 180
Code: [Select]
      // strip base path from request url
        $requestUrl = substr($requestUrl, strlen($this->basePath));
if( substr($requestUrl, -1) === "/" ){
$requestUrl = substr($requestUrl, 0, -1);
}
// Strip query string (?a=b) from Request Url
Title: Re: public-profile url format
Post by: Sophia_OS on May 16, 2019, 09:49:58 am
@Web-Media,
Awesome! Thank you very much!
now let's make this plugin even more powerful by adding search system to this plugin!
i'm waiting for your response!
Thanks again!
Title: Re: public-profile url format
Post by: Web-Media on May 16, 2019, 01:01:33 pm
Hy.   This will have to wait a little .
I'm working on rewriting  some  osclass core code .. without breaking existing installs.
And second .. rewrite from scratch importing external libraries and classes
Title: Re: public-profile url format
Post by: Sophia_OS on May 16, 2019, 02:34:27 pm
@Web-Media,
Sure, please update here as soon as possible!
Thank you very much!