Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Nothing Working – Assets Not Loading? #3

Closed
cd13sr opened this issue May 5, 2016 · 13 comments
Closed

Nothing Working – Assets Not Loading? #3

cd13sr opened this issue May 5, 2016 · 13 comments

Comments

@cd13sr
Copy link

cd13sr commented May 5, 2016

For whatever reason none of these shortcodes are working for me. It seems like the JS and CSS assets are not being loaded. If those assets are supposed to be in the rendered page HTML, I'm not seeing them. Any thoughts?

Thanks!

@flaviocopes
Copy link
Contributor

Tested it briefly, can't get the js/css assets loaded too. Seems the onPageInitialized, where the assets of the page are added to Grav, fires before onPageContentProcessed, where the assets are added to the page.

Is this possible @rhukster?

@rhukster
Copy link
Member

rhukster commented May 6, 2016

This is working fine for me. Can i get a list of plugins you guys are using? Or perhaps, can you try turning off plugins until (hopefully) it starts working?

@rhukster
Copy link
Member

rhukster commented May 6, 2016

onPageContentProcessed() is where the shortcode assets are gathered and stored in the page's content metadata. This is called from within the Page::content() method.

https://github.com/getgrav/grav/blob/develop/system/src/Grav/Common/Page/Page.php#L582

Then in onPageInitialized() these are pulled out of the page's metadata and added to the assets. However, I have some code that forces the calling of content() so the onPageContentProcessed() is forced to be called if it has not been so already:

        // Initialize all page content up front before Twig happens
        if (isset($page->header()->content['items'])) {
            foreach ($page->collection() as $item) {
                $item->content();
            }
        } else {
            $page->content();
        }

So even though onPageInitialized() could be called first, it will call, content() which will in turn call onPageContentProcessed() and process the assets before they are needed.

So I will need you guys to provide me a sample Grav config/setup where this happens so I can debug, as it works fine for me in all my testing.

@cd13sr
Copy link
Author

cd13sr commented May 6, 2016

Thanks @rhukster, I won't be able to get you my test site until Monday. I did try this on a fresh install with the Admin plugin and it works fine. So, as you said, maybe it's another plugin conflicting with it.

Thanks.

@cd13sr
Copy link
Author

cd13sr commented May 9, 2016

Hey @rhukster, here's a sample site where it's not working.

Thanks!

grav.zip

@rhukster
Copy link
Member

rhukster commented May 9, 2016

Thanks for the zip, what exactly am i looking for?

@cd13sr
Copy link
Author

cd13sr commented May 9, 2016

You mentioned that you wanted a sample Grav config/setup where this issue happens. So, I just zipped up the entire site for you.

@rhukster
Copy link
Member

rhukster commented May 9, 2016

Ok, I found the problem, fixed it, and re-released shortcode-core as v2.2.1. It should show up in < 30 mins.

FWIW, the problem was on page that had a content collection defined, it was not initializing the current page in that case as i had only tested on a blog page where there was no shortcode in the blog listing page. Silly mistake, but an easy fix :)

@rhukster rhukster closed this as completed May 9, 2016
@rhukster
Copy link
Member

rhukster commented May 9, 2016

This was the fix: getgrav/grav-plugin-shortcode-core@c6d9763

@rhukster
Copy link
Member

rhukster commented May 9, 2016

I was using tester-2 page as that was the page I could see a couple of Shortcode-UI calls. Works with my fix.

@cd13sr
Copy link
Author

cd13sr commented May 9, 2016

Awesome, thanks!

@cord
Copy link
Contributor

cord commented Feb 8, 2017

Hi andy,

latest grav and plugin version:

on a modular page the assets (js+css) are not added when a subpage utilizes a shortcode. The shortcode itself is processed (html structure created)

workaround:

insert a shortcode in html comments
<!-- [ui-animated-text words="" animation="rotate-1" element="h2"][/ui-animated-text] -->

at the and of the modular.md

so looks like the the ->addAssets() calls are fired too late?

@joelluethi
Copy link

Hi, I have the problem that my assets are not loading anymore. I tried turning off plugins and the workaround @cord posted here, both of the options didn't work for me.

Is someone having the same issues?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants