- This topic has 7 replies, 3 voices, and was last updated 2 years, 12 months ago by
Fernando.
-
AuthorPosts
-
March 20, 2023 at 11:38 am #2574611
Jusung
Refering this.
https://generatepress.com/forums/topic/current-color-of-a-button/I am trying to make current color on a button.
So, I gave class to each color and changed the color based on a unique body class.So, if you see first and second link, you can see the current color on a button.
However, Some pages don’t have a unique class.
You can log in with the account I provided, and go to 계정(my account)
There you can see 4 buttons that don’t have current color.It has different link, but have the same body class.
So, I can’t set the current color on a button.In this case, how can I find the unique class that can be used for button..?
Am I supposed to give unique class to a certain url by adding php code..?
Or is there other way to make this work.?I think this is out of scope,
but could you just give me an idea?
So, I will try to make this on my own.March 20, 2023 at 12:06 pm #2574651Ying
StaffCustomer SupportHowever, Some pages don’t have a unique class.
You can log in with the account I provided, and go to 계정(my account)Do you mean you don’t find the unique class for the account page?
If so, try this:.woocommerce-accountMarch 20, 2023 at 9:53 pm #2574971Jusung
I mean on the account page, there are different options such as order, address, profile and so on.
I also have added extra menu on my account page, which doesn’t have any unique body class.
/my-account/menu1
/my-account/menu2
like this, each link should have a unque body class, but on my end, I can’t find any unique body class.March 20, 2023 at 10:11 pm #2574979Fernando Customer Support
Hi Jusung,
Can you share the login link as well?
Please use the Private Information field for this: https://docs.generatepress.com/article/using-the-premium-support-forum/#private-information
March 22, 2023 at 12:13 pm #2577473Jusung
Yes. Here is the login link,
On this link, you can login with the account I provide.
And you can go to 계정 on the menu.There you can see 4 buttons I made.
excepts for 주문, the other 3 buttrons don’t have any unique body class.March 22, 2023 at 3:34 pm #2577719Ying
StaffCustomer SupportDo you want these buttons that are on the same page to have different dynamic colours while they share the same body class?
If so, it’s not possible. I would recommend using static color in this case.
March 22, 2023 at 8:14 pm #2577943Jusung
I mean, those 4 buttons have different URL.
So, based on the URL, I want to set different color.
To make this, I need a unique body class.If you see 스토어 or 블로그, you can see different color of buttons based on the page.
It is because The page of those buttons has a unique body class.So, on my guessing, I have to give a unique body class to a certain link.
So, I can make it.<script> if(window.location.href.match('aeollure.com/my-account/msreview/')){ jQuery('body').addClass('msreview1'); }else if(window.location.href.match('aeollure.com/my-account/address-book/')) { $('body').addClass('address-book'); }else if(window.location.href.match('aeollure.com/my-account/msm-profile/')) { $('body').addClass('msm-profile1'); } </script>I am trying this, but not workign.
March 22, 2023 at 9:10 pm #2577989Fernando Customer Support
You can try using PHP instead.
generate_hook_element_displayfilter could help.Add your CSS through a Hook Element. Then, add a snippet like this:
add_filter( 'generate_hook_element_display', function( $display, $element_id ) { $url = 'http://' . $_SERVER['SERVER_NAME'] . $_SERVER['REQUEST_URI']; if ( 100 === $element_id && strpos($url,'my-account/msreview/') !== false ) { $display = true; } return $display; }, 10, 2 );Replace
100with your Element ID:Getting the Element ID: https://share.getcloudapp.com/YEuDdrnQ
Just make new instances of the Hook Element and the code for every page.
-
AuthorPosts
- You must be logged in to reply to this topic.