Search code examples
packageconcrete5singlepage

Concrete5: Take the central part of my single page and have it displayed on the homepage


Within my Concrete5 there's a package that contains many single pages, which actually make the core functionality (community connections).

There's one particular page that contains search functionality. Is there any way to take the central part of that page and somehow display it on the homepage, in a div element or similar?


Solution

  • You should be able to do this by creating a new public function in the single_page's controller that returns whatever you want it to (data that you can then render in HTML, or you could have the controller method itself render an "element" with some data, or just create an HTML string in the controller method itself if you want to totally violate the MVC pattern).

    Then you should be able to retrieve that data or markup from your other page like so:

    $myController = Loader::controller('/path/to/singlepage'); //<--NOTE this is a C5 URL path (e.g. "slug"), not a server file path!
    $myMarkup = $myController->myCustomFunctionIWroteToReturnSomeStuff();
    echo $myMarkup;