• Hello there πŸ˜‰

    first thanks a lot for this nice plugin!

    I’m using the OnePress Theme which features a one-pager layout.

    In this one pager layout I can add sections where the content of the section is defined in a page. So I create the page and add the ultimate blocks and all is fine. If I view the page the ultimate blocks are working properly.

    If I then add the content of that page to a section of the one-pager layout the styles are missing and ultimate blocks don’t display properly.

    I see ultimate blocks is optimized for speed and first checks if there are any blocks in the content of the page. if it finds some blocks it loads the ultimate blocks css styles.

    with this special onepager layout and loading content of other pages into the sections of the onepager it doesn’t seem to detect any ultimate blocks and thereby doesn’t load the css.

    is there some sort of filter / action which let’s me force to load the css? Or are there any other options the get the css loaded?

    thanks & greetings
    Becki

Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Contributor Alexis Pandaan

    (@alexius08)

    Hi @becki! You can load the CSS via the enqueue_block_assets hook. Don’t forget to use the is_home() and is_front_page() functions to ensure that your function for loading the plugin CSS is only called in the one-pager layout.

    Thread Starter Becki Beckmann

    (@becki)

    Hello @alexius08,

    thanks a lot for your reply πŸ˜‰

    I will have a look into the hook you provided. Does this hook only load the CSS or also the javascript needed?

    For example, I use the content toggle block and also the progress bar block. when using these blocks some additional javascript is loaded:

    /wp-content/plugins/ultimate-blocks/src/blocks/content-toggle/front.build.js
    /wp-content/plugins/ultimate-blocks/src/blocks/progress-bar/front.build.js

    how can I load the necessary javascript?

    As a workaround I just copied the content of the page used in the one-pager section into the content of the one-pager page.

    this one-pager page uses a special frontpage template to render the one-pager with all its sections.

    the content of the one-pager page itself never gets displayed. But this way ultimate blocks will inspect the content and load the CSS and JS.

    But it’s not a nice solution as I always need to copy between pages when updating content.

    there must be a more elegant solution?

    anyone?

    thanks & greetings
    Becki

    Plugin Contributor Alexis Pandaan

    (@alexius08)

    Hi @becki! We use the enqueue_block_assets hook to load the CSS file (which contains the CSS for all blocks), while the frontend Javascript files (used separately by certain blocks) are loaded via the wp_enqueue_scripts hook.

    The simplest solution would be adding functions for loading the CSS/JS files into their respective hooks and loading them whenever the special frontpage template is detected (which is where the is_home and is_front_page functions would come to play). You may check how we load the CSS file here and each frontend Javascript file in this example.

    Thread Starter Becki Beckmann

    (@becki)

    Hi @alexius08,

    thanks again for your reply & help guding me to the proper information.
    your help is much appreciated!

    I will look into it later but consider this topic resolved.

    thanks, greetings
    & keep up the good work you’re doing
    Becki

Viewing 4 replies - 1 through 4 (of 4 total)

The topic ‘Onepress Theme – ultimate blocks styles not loading’ is closed to new replies.