Question

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?

Was it helpful?

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;

OTHER TIPS

You can do this with jquery .load() On the single page, wrap the content you want to import in a div with a unique id. On the home page, add a div to import the content into

// Get the URL of the page
var url = "relative/path/to/page;

// Load the new page into the temp container
// Replace #wrapper with the selector of the element you want to import
$("#import-content").load(url + " #wrapper");
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top