Navigation überspringen

[Gelöst] Condition in View that depends on intermediary post

This support ticket is created vor 4 Jahren, 4 Monaten. 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.

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)

Dieses Thema enthält 33 Antworten, hat 2 Stimmen.

Zuletzt aktualisiert von AlimB3245 vor 4 Jahren, 4 Monaten.

Assistiert von: Minesh.

Author
Artikel
#1748113
Screen Shot 2020-08-21 at 9.32.15 PM.png

HI Minesh

It seems to be working..:-)..

but there's some empty space or spaces before the ids... please check screenshot at the bottom of the browser.. can you please fix that?

Regards,
alim

#1748123

Minesh
Supporter

Sprachen: Englisch (English )

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

Glad to know that the solution I shared is working.

I've removed all the space from view and if you still see the space, you can handle it grammatically when you catch the URL param value and split with comma.
=> versteckter Link

#1748125
Screen Shot 2020-08-21 at 9.44.50 PM.png

Hi Minesh

I changed the user-store to India
then for FourPlus Vision which had only AE connected brands, I added one brand to IN in the eyewear store (screenshot attached)

Now when the optician whose user-store is IN visit's Dr Harmann's brand owner he is able to see brand 875 which is correct but when he visits FourPlus Vision he should also see another brand id for Cali4nia.. but there are no brand ids displayed..

Please check..

Regards,
Alim

#1748139

Minesh
Supporter

Sprachen: Englisch (English )

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

when he visits FourPlus Vision he should also see another brand id for Cali4nia..
==>
What is the URL I need to visit? Can you lease share that.

#1748141

versteckter Link

This is the brand owner who has 3 brands for AE and one brand (Cali4nia) for AE and IN.. so this brand-id should have displayed for the optician whose user-store is IN

Regards,
Alim

#1748147

Sharing this .. just in case it helps.. as we were having some issues recently with IF condition on multiple checkboxes and Christian found something that helped..

https://toolset.com/forums/topic/if-condition-for-a-custom-field-with-multiple-checkboxes/

Regards,
Alim

#1748189

Would it be possible if there are no brand ids, we are able to display the message from
[wpv-no-items-found][wpml-string context="wpv-views"]No items found[/wpml-string]
[/wpv-no-items-found]

Based on what's displayed as the result there will be an action where the URL is directed.. currently it was set to 'No items found'... we can change it ... but if it's possible do let me know if we can avoid the multiple blank commas (,,,) and instead go to the [wpv-no-items-found] section..

Regards,
Alim

#1748703

Minesh
Supporter

Sprachen: Englisch (English )

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

As you have multiple values that is returned from the checkboxes custom field and there is no way to compare the multiple values return by checkboxes field using native shortcodes.

As a workaround, i've added the following shortcode to your current theme's functions.php file:


function func_check_user_store_value() {
   global $current_user;
    
  $eyewear_store_value = do_shortcode("[types field='eyewear-store' output='raw' item='@brand-distributor-eyewear-brand.intermediary'][/types]");
  $user_store = do_shortcode("[types usermeta='user-store' output='raw' current_user='true'][/types]");
  
  if(strpos($eyewear_store_value, $user_store) !== false){
    return 1;
  } else {
    return 0;
  }
  
}
add_shortcode( 'check-user-store-value', 'func_check_user_store_value' );

And updated the conditional statement as given under to your view:
=> versteckter Link

<wpv-loop>[wpv-item index=other][wpv-conditional if="( '[check-user-store-value]' eq '1' )" ][types field="id" output="raw"][/types][/wpv-conditional],[wpv-item index=last][wpv-conditional if="( '[check-user-store-value]' eq '1' )"][types field="id" output="raw"][/types][/wpv-conditional]</wpv-loop>

Can you please confirm it works as expected now.

Please feel free to open a new ticket with your every new question you may have. Have a great weekend 🙂

#1748711

Hi Minesh

Thanks for the update..:-).. will test right away..

In the meantime could you put the function in the toolset customizations section? It's easier for me to trace all toolset functions to this location as I have some from WPMU and others and it could get confusing..

And yes, I'll send you the other questions as a new ticket..:-)..

Have a nice weekend..:-)..

Regards,
Alim

#1748725

Minesh
Supporter

Sprachen: Englisch (English )

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

I tried but I do not have rights to add that custom code to Toolset's "Custom Code" section.

Please check the following screenshot: versteckter Link

You can move it on your own and please feel free to mark resolve this long conversation eventually ended with solution as per your requirement.

#1749677

Hi Minesh

Thanks for the update..:-)..

I've add the custom code to the Toolset Custom Code section here.. versteckter Link

and commented it out from the functions.php..

I need one small update in the code..

How do I get rid of the commas when the result is null or nothing?

I would assume that if we added the comma as a prefix to the 'next' (not the first) values it would be solved... but I am not really a developer so not sure if this is the best way to do this.. please do advise and fix as I'd like to have a null or blank value when there is not brands in the result rather than a series of commas.

Regards,
Alim

#1753083
Screen Shot 2020-08-24 at 9.56.21 AM.png

Hi Minesh

Once you've resolved the commas issue, please do check these other views that I have created..

versteckter Link
versteckter Link
versteckter Link
versteckter Link

Thanks to the custom-code that you provided my questions to you were reduced as I could use that code for the other related views..;-).. but please do check if I have done it right..

In the meantime I had a few other queries but I could not create a new support ticket on toolset.. the site would just wait with a blank page and at the bottom of the screen we had this message Waiting for bam.nr-data.net .. (screenshot attached)..

Regards,
Alim

Neue Threads, die von Minesh erstellt wurden und mit diesem verbunden sind, sind unten aufgeführt:

https://toolset.com/de/forums/topic/split-condition-in-view-that-depends-on-intermediary-post-comma-separated-view/

#1753093

Hi Minesh

As I am not able to create a new support ticket I will put the queries here (before I forget) and you can please split this thread to a new ticket.

QUESTION 1
I have a post (Eyewear Collection) which has a parent (Brand) and Brand has a parent (Brand Owner).. When I am on the Eyewear Collection Profile Template (Single Page).. I need to get the Brand Owner's ID, Name, Email and Mobile [types field="wpcf-organisation-email' output ='raw'] and [wpv-post-title].. if I had to get it for the Brand, I would have done this..

[types field="wpcf-organisation-email' @item='eyewear-brand-eyewear-collection.parent' output ='raw']
and
[wpv-post-title @item='eyewear-brand-eyewear-collection.parent' ] (would this be right? for wpv-post-title?)

But I don't know how to get it for the Brand Owner (who is the grand parent of eyewear collection).. please advise.

Also I would need to run the condition you helped me with above (function func_check_user_store_value()) to check if the user-store is equal to the brand owner's eyewear-store.. so please advise how I can do this..

QUESTION 2
When I display [types field='repeatable-group-field'] the multiple instances that are displayed are separated by space.. I would like to have them separated by commas... how can I do this?

Please feel free to make 2 separate tickets of this if you wish.

Thanks in advance.. Have a nice day..:-)..

Regards,
Alim

#1753161

Minesh
Supporter

Sprachen: Englisch (English )

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

I've updated the following view so it will display the comma only if the ID is available.
=> versteckter Link

Can you please verify that and let me know and mark resolve this ticket. I will split the ticket with your additional replies and additional questions..

#1753277

Hi Minesh..

The youandeye site seems to be broken.. CSS not loading.. the other subsites seem to be fine..

Is it because of what we are doing?

Regards,
Alim