Skip Navigation

[Resuelto] If current page not working in template file…

This support ticket is created hace 8 años. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

No supporters are available to work today on Toolset forum. Feel free to create tickets and we will handle it as soon as we are online. Thank you for your understanding.

Sun Mon Tue Wed Thu Fri Sat
- 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 -
- 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 -

Supporter timezone: Asia/Kolkata (GMT+05:30)

Etiquetado: 

This topic contains 6 respuestas, has 2 mensajes.

Last updated by thomasS-11 hace 7 años, 12 meses.

Assisted by: Minesh.

Autor
Mensajes
#392477

Continuation from: https://toolset.com/forums/topic/if-current-page-not-working-in-template-file/

I marked the thread "Fixed" as i thought it was, but it wasnt at all.
My problem from https://toolset.com/forums/topic/if-current-page-not-working-in-template-file/ is still a problem. It does not show the correct class at the correct item which is current page.

Url: Omsorgscentret.dk - you can see the nav class does not get added to the current page item.

#392520

Minesh
Supporter

Languages: Inglés (English )

Timezone: Asia/Kolkata (GMT+05:30)

Hello. Thank you for contacting the Toolset support.

1)
Could you please share problem URL?

2)
*** Please make a FULL BACKUP of your database and website.***
I would also eventually need to request temporary access (WP-Admin and FTP) to your site. Preferably to a test site where the problem has been replicated if possible in order to be of better help and check if some configurations might need to be changed.

I would additionally need your permission to de- and re-activate Plugins and the Theme, and to change configurations on the site. This is also a reason the backup is really important. If you agree to this, please use the form fields I have enabled below to provide temporary access details (wp-admin and FTP).

I have set the next reply to private which means only you and I have access to it.

#392954

Minesh
Supporter

Languages: Inglés (English )

Timezone: Asia/Kolkata (GMT+05:30)

I went through you views code and I found some syntax error with [wpv-conditional] shortcode statement.

Now, as I understand you want to add class="active" to the selected menu user selected. Could you please confirm or guide me if I'm wrong.

#393009

Hi Minesh.

Hm. I have re-viewed the code, and I personally cannot see any syntax errors.
None are fixed either, the active class is still not added to the current page.

And yes, that is exactly what i am trying to achieve.

#393198

Minesh
Supporter

Languages: Inglés (English )

Timezone: Asia/Kolkata (GMT+05:30)

I've added the following code to your view's JS box.

jQuery(document).ready(function($){
  href = window.location.href;
  x = href.split('/');
  x = x[x.length-2];
  var locations = new Array("omsorgscentret.dk", "hvem-kan-faa-hjaelp", "formaal","vi-tilbyder");
  current = locations.indexOf(x) + 1;
  $('#main-nav li:nth-child('+current+')').addClass('active');
});

Could you please check your issue and confirm this solution help you to resolve your issue.

#393306

I will NOT take this solution as "resolved". - Actually im very disapointed that you bring up this hotfix for a solution.

Making a jQuery solution to the problem is not a fix.. Or at least, its not a fix i want to use at all.
It does not answer the question i posted, that the conditional statements are not working properly.

Thanks for your try, but i will not accept this as a solution - i could have done this myself but i want a solution for the future. If the Conditional statements doesnt work properly in Views, how dare someone to bring a jQuery fix to it? Im sorry but this fix had me a little bit upset, as i did not at all expect this as a serious solution to why Conditional is not working.

Also you have hardcoded the URL names into a array, which for me seems useless. Do you expect the clients to add a new string to the array each time they add a new page?

Please, if it cant be fixed because of the code is wrong, REPORT it to the dev team instead of jQuerying around it..

#393329

Minesh
Supporter

Languages: Inglés (English )

Timezone: Asia/Kolkata (GMT+05:30)

On my local when I use [wpv-post-id id="$current_page"] shortcode it gives me right page ID.

However - on your install it's not working right. It seems to me that this is your live site. That's the reason I gave you the alternate solution. if you would not like to go with jQuery solution - never mind and I kindly apologise for same.

I would like to do some test with the default theme and with/without plugins.

Could you please give me test site or is it OK for you if I should make a test with this current site?

This ticket is now closed. If you're a WPML client and need related help, please open a new support ticket.