Jump to content

Using RSS loader inside a function


jsantari
 Share

Recommended Posts

I've got some front end code that I want to load a RSS feed using the MarkupLoadRSS module. I can get it to work from my template but I want to use it to load dynamically from a function I have. Inside the function it does not see the $modules object when trying to do a get for the module. How should I reference the $modules object within my function?

Link to comment
Share on other sites

Inside functions you need to use:

wire('modules')->

Same goes for wire('pages') etc.

This is due to variable scope issues:

http://php.net/manual/en/language.variables.scope.php

If you are ever writing a long function where one of the PW variables is used many times, you can always define it at the top of the function:

eg: $modules = wire('modules');

  • Like 1
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...