Keyword

Сorrect comparison of the current Url

  • Roman Lipatov
  • Roman Lipatov's Avatar Topic Author
  • Offline
  • Premium Member
More
7 years 4 months ago - 7 years 4 months ago #159526 by Roman Lipatov
Сorrect comparison of the current Url was created by Roman Lipatov
Hi!
I need to add new class for current item in K2_content module.

I get result with this code:
<?php if (JURI::current() == ("https://site.com".$item->link)): 
	$currentweek = "currentweek";
else: 
	$currentweek = false;
endif;
?>

but in not universal.

I tried this code:
<?php if (JURI::current() == (JURI::base().$item->link)): 
	$currentweek = "currentweek";
else: 
	$currentweek = false;
endif;
?>

But in this case urls have extra slash:

site.com//item_path/


How I can fix it?
Thanks.
Last edit: 7 years 4 months ago by Roman Lipatov.

Please Log in or Create an account to join the conversation.

  • Krikor Boghossian
  • Krikor Boghossian's Avatar
  • Offline
  • Platinum Member
More
7 years 4 months ago #159573 by Krikor Boghossian
Replied by Krikor Boghossian on topic Сorrect comparison of the current Url
You can use str_replace to remove the double slashes.
Depending on the context $item->absoluteURL migh help.
However I don't really see the big picture here.
I would opt-in for a JS based solution.

JoomlaWorks Support Team
---
Please search the forum before posting a new topic :)

Please Log in or Create an account to join the conversation.


Powered by Kunena Forum