Tab visible? Active Tab?

This topic contains 10 replies, has 3 voices, and was last updated by  Alex Rollin 6 years, 8 months ago.

We have moved to a support ticketing system and our forums are now closed.

Open Support Ticket

Tagged: , ,

  • Author
    Posts
  • #422845

    jahusdtc
    Expired Member
    Post count: 162

    On Supreme theme, on Details page…

    I would like to automatically add a LINK TO the Video Tab (created with custom fields under fieldset) DISPLAYED ON the Profile Tab.

    Why do this?

    I know the authors won’t be able to add the shortcode properly (changing to Text Mode in editor will baffle them), so if I can just automatically put in the link to another tab, it would be much more effective.

    To do this, I figure I need to know 1) IF there’s a Video tab visible (or I could just check whether custom fields are empty?) and 2) if I’m in the Profile tab.

    Any suggestions or examples you might point me to? Checked out the Codex, but couldn’t see anything related to this regarding “Tab” or “Tabs.”

    Would appreciate any clues.

    #422848

    jahusdtc
    Expired Member
    Post count: 162

    Okay, think I figured out #2…the answer is here:
    https://wpgeodirectory.com/support/search/?bbp_search=add+content+to+tab

    But still #1 is pending.

    Best way to handle?

    #422853

    jahusdtc
    Expired Member
    Post count: 162

    Okay, a step further, but…I note that the div coloration extends beyond the a href in my attached image. Can you help me with making it “stop” at the end of the words?

    And would still like to know if I can tell if particular “tab” is showing.

    Here’s my code, in case it helps someone else:

    BTW, the tab I’m trying to add to is the Profile tab, the custom fields are video_1 and video_2.

    This code does NOT check if Video tab is visible — which would be a very nice thing to know — but it DOES check the custom fields that are ON the Video tab. If they’re “filled”, the tab is showing.

    add_action(‘geodir_after_tab_content’,’_my_tab_content_after_x’);
    function _my_tab_content_after_x($tab){
    //echo ‘Tester – tab is ‘ . $tab;
    if($tab== ‘post_profile’){
    if (!(empty(geodir_video_1) or (empty(geodir_video_2))) )
    {
    /*CSS already in stylesheet*/
    $the_string_to_add = ‘<div class=”checkoutourvideo”>Go ahead…Check out our video for more info.</div’;

    echo $the_string_to_add;
    } //custom fields are “filled” so tab shows
    } //tab is the profile tab
    } //_my_tab_content_after_x

    FYI, the CSS I used was:
    div.checkoutourvideo a, div.checkoutourvideo a:hover{color:yellow;margin-top:15px;font-weight:500;}
    div.checkoutourvideo {background:#173587;padding:9px;margin-top:20px;}

    NOTE: The href does not yet go from Profile tab to the Video tab itself. Think Geodirectory forum has helpfully given the solution elsewhere for that! That’s tomorrow’s project!

    #422855

    jahusdtc
    Expired Member
    Post count: 162
    This reply has been marked as private.
    #422878

    Guust
    Moderator
    Post count: 29970

    Please review https://wpgeodirectory.com/re-order-tabs-in-a-listing-detail-page/
    Setting the video tab to be the firs tab should sort your problem.

    #423049

    jahusdtc
    Expired Member
    Post count: 162

    Thanks, Guust!

    However, I have a feeling I didn’t communicate well.

    My Video tab (created with fieldset and two custom fields) is showing fine. Doesn’t need to be re-ordered at present.

    What I WOULD like to find out is how to tell whether or not a Tab is actually showing (because it has values in the custom fields that make it up) … OR … if it’s hidden (because it has NO values in the custom fields that make it up.)

    That way I wouldn’t have to check individual field values. Instead, I could just check if the Tab is showing.

    That way if I ADD custom fields to the tab, I don’t have to continually go back and add those individual custom fields to my conditional statement.

    Right now I have to do:
    //Assess whether there’s ANY video (custom field) in their
    //own tab.
    $theres_a_video =
    ((isset($post->geodir_video1) && $post->geodir_video1) ||
    (isset($post->geodir_video2) && $post->geodir_video2));

    Problem would be…if I added an additional custom field named Video3 field, I’d have to remember to come back here and change the code.

    If instead, I could just say something like (pseudo code)
    $theres_a_video = Video Tab is Showing
    then I could just forget about the code and let it just work.

    Is this any clearer? I don’t know if there’s a function that would give me the “Video Tab is Showing” value, but it would be helpful.

    #423054

    Guust
    Moderator
    Post count: 29970

    So if I understand correctly:
    If a listing has at least one custom field populated in a particular fieldset (the video tab), then you want to print a link to that tab on the same page, but in the profile tab.

    Right?

    #423062

    jahusdtc
    Expired Member
    Post count: 162

    100% correct!

    Thought there might be handy variable or function that would tell me whether ANYTHING was visible because it was populated. (Must remember that term…populated is much more descriptive than “filled.”)

    Thanks!

    #423139

    Alex Rollin
    Moderator
    Post count: 27815
    #423156

    jahusdtc
    Expired Member
    Post count: 162

    Hey, Alex…you got me started in the right direction! Thanks!

    Using your tips, I started exploring. Post was not actually what I needed, but testing that started me thinking.

    Took me several hours to figure out…but answer was whole lot easier than I thought.

    Here goes for someone else who might want to accomplish this. It’s what I used to “test” whether Tab is visible on the Detail Page (in Supreme Directory Theme anyway.)

    I am using it in functions.php when I need to figure out if tab even exists for particular listing.

    
    
    /*
    Use this if want to see if tab is actually showing.
    Here, my tab gd_tab_2 is a tab created by adding custom field fieldset with two custom fields below it.  
    
    Don't want to test existance or population of custom fields separately.  Instead want to see if tab exists -- because GeoDirectory has already determined SOME field in the fieldset (tab) is populated.  GeoDirectory has done the heavy lifting for me with this function...no point in me repeating that!
    */
    
       $my_list_of_tabs = geodir_detail_page_tabs_list();
       $video_tab_showing = (isset($my_list_of_tabs['gd_tab_2']))
       if ($video_tab_showing) {echo 'YES...it shows';} else {echo 'NOPE...not showing';}
    #423222

    Alex Rollin
    Moderator
    Post count: 27815

    Excellent!

Viewing 11 posts - 1 through 11 (of 11 total)

We have moved to a support ticketing system and our forums are now closed.

Open Support Ticket
20% Discount Offer
Hurry! Get your 20% discount before it expires. Get 20% Discount