Viewing 14 posts - 1 through 14 (of 14 total)
  • Author
    Posts
  • #1194759

    (German below)
    Hi Kriesi team,
    I would like to open several hidden color sections on one page using several buttons (one button per section).
    I assigned a unique class to the button and assigned a unique ID to the color section to be opened.

    Then I used this code from Yigit (https://kriesi.at/support/topic/hidding-color-section/):

    function add_custom_cs () {
    ?>
    <script>
    jQuery (window) .load (function () {
    jQuery (“# ​​your-unique-color-section-id”). hide ();
    jQuery (“.your-custom-button-class”) .click (function () {
    jQuery (“# ​​your-unique-color-section-id”) .toggle ();
    });
    });
    </script>
    <? php
    }
    add_action (‘wp_footer’, ‘add_custom_cs’);

    The code works great as long as I have defined one button and a section and the information is used accordingly in the code.
    The moment I adjust the code for another section, I get a critical error.
    Can you help me?
    Best regards
    Grobi

    _____________________________
    Hi Kriesi-Team,
    ich möchte mehrere versteckte Color-Sections auf einer Seite über entsprechend mehrere Buttons öffnen (ein Button pro Section).
    Ich habe dazu dem Button eine einzigartige Klasse zugeteilt und der zu öffnenden Color-Section eine einzigartige ID zugewiesen.

    Danach habe ich diesen Code von Yigit (https://kriesi.at/support/topic/hidding-color-section/) verwendet:

    function add_custom_cs(){
    ?>
    <script>
    jQuery(window).load(function(){
    jQuery(“#your-unique-color-section-id”).hide();
    jQuery( “.your-custom-button-class” ).click(function() {
    jQuery( “#your-unique-color-section-id” ).toggle();
    });
    });
    </script>
    <?php
    }
    add_action(‘wp_footer’, ‘add_custom_cs’);

    Der Code funktioniert super, solange ich einen Button und eine Section definiert habe und die Angaben entsprechend im Code eingesetzt sind.
    In dem Moment, wo ich den Code für eine weitere Section anpasse, erhalte ich einen kritischen Fehler.
    Könnt ihr mir helfen?

    Liebe Grüße
    Grobi

    #1198013

    Hey Grobi,

    You need to use different function names or combine the code in one function.

    If you need further assistance please let us know.
    Best regards,
    Victoria

    #1198014

    Hi Victoria,
    can you tell me how?
    I tried to copy the code and filled it up with the next classes and ids, but this does not work.

    I hope you can help me.
    Best regards
    Grobi

    #1198347

    …unfortunately I am not able to edit php-code…. :-(

    #1198596

    Hi Grobi,

    Can you give us temporary admin access to your website in the private content box below, so that we can have a closer look?

    Best regards,
    Victoria

    #1198888

    Dear Victoria,
    thank you for taking care.

    Unfortunately, the page in question is only offline on my computer, but I have now transferred the content and code for the functions.php to an online site so that I can show it to you.
    You find the address and login credentials below.

    My problem remains the same here: I would have to change Ygits PHP code so that I can hide and open several color sections – even on different pages – which I unfortunately cannot do due to a lack of knowledge of PHP. The first button (with its own ID) opens the desired section perfectly, the remaining sections to be closed remain open – in the absence of code – of course.

    Best regards – and please stay healthy.
    Grobi

    #1199399

    Hi Grobi,

    Which other section do you need to toggle and what is the button?

    Best regards,
    Victoria

    #1199439
    This reply has been marked as private.
    #1200635

    Hi Grobi,

    Please try using this code:

    
    function add_custom_cs(){
    ?>
    	<script>
    	jQuery(window).load(function(){
    		jQuery("#hide_company").hide();
    		jQuery("#hide_technology").hide();
    		jQuery("#hide_product").hide();
    		jQuery("#hide_sustainability").hide();
    		jQuery( ".companyschalter" ).click(function() {
    			jQuery( "#hide_company" ).toggle();
    		});
    		jQuery( ".technologyschalter" ).click(function() {
    			jQuery( "#hide_technology" ).toggle();
    		});
    		jQuery( ".productschalter" ).click(function() {
    			jQuery( "#hide_product"  ).toggle();
    		});
    		jQuery( ".sustainabilityschalter" ).click(function() {
    			jQuery( "#hide_sustainability" ).toggle();
    		});
    	});
    	</script>
    <?php
    }
    add_action('wp_footer', 'add_custom_cs');
    

    Best regards,
    Victoria

    #1200783

    Hi Victoria,
    thanks for the code.
    Unfortunately it does not work, I get this error-message:
    “Parse error: syntax error, unexpected ‘?’ in /homepages/10/d85211480/htdocs/subd_foo/wp-content/themes/enfold/functions.php on line 47”

    Watch this screenshot, please: [img]https://i.imgur.com/yusyZYP.png?1[/img]

    To make my website work again, I comment out the code temporarily. I hope that’s OK for you.
    Best regards
    Grobi

    #1200784
    This reply has been marked as private.
    #1201359

    Hi Grobi,

    https://share.getcloudapp.com/eDuxN1L2Please pay attention and edit the signs. You have there “;& l t” and it should be > ant the other one. Please check the code and edit it there.

    Best regards,
    Victoria

    #1201522

    Hi Victoria.
    Thank you very much – now it works.
    I have no idea how that happened. I’m pretty sure that I haven’t saved the script anywhere. But, that seems to be a mistake on my part …

    Victoria, I have one more question to the behaviour of the opened section:
    if you have opened the section, the page scrolls to the head of the section in which the button is located – but unfortunately not to the new content that has just opened.
    Can you adjust that?

    Best regards
    Grobi

    #1201556

    An addandum:
    The effect I have described relates to the page I am working on offline. On the side accessible to you, Victoria, the effect is slightly different. Here the page remains in place after clicking on the button. But here, too, it would be great if the page would scroll to the coolor section that was just opened.

    Best regards
    Grobi

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

You must be logged in to reply to this topic.