Hello! Is it possible to display files in a category using the Phoca Download plugin? I would like the files to be shown with download and preview buttons, as in the phoca download component.
Before I was doing this using the Components Anywhere plugin, but it is not available for Joomla 4.
I want to achieve something like this page:
https://www.phoca.cz/download/category/ ... -component
where the files for download are displayed within other text in the page.
Thank you!
Display files in a category using the plugin
-
- Phoca Newbie
- Posts: 2
- Joined: 23 May 2023, 18:48
-
- Phoca Newbie
- Posts: 2
- Joined: 23 May 2023, 18:48
Re: Display files in a category using the plugin
Just in case it is useful for somebody else, what I did is a custom html module to get the html between body tags in the page, putting the php code using sourcerer.
This is the content of the module:
{source}
<?php
function getHtmlWithinBody($url) {
// Read the URL and get the HTML content
$html = file_get_contents($url);
// Create a DOM document
$dom = new DOMDocument();
// Disable error reporting for HTML parsing
libxml_use_internal_errors(true);
// Load the HTML content into the DOM document
$dom->loadHTML($html);
// Enable error reporting again
libxml_use_internal_errors(false);
// Find the body element
$body = $dom->getElementsByTagName('body')->item(0);
// Check if the body element exists
if ($body) {
// Get the inner HTML of the body element
$innerHtml = '';
foreach ($body->childNodes as $node) {
$innerHtml .= $dom->saveHTML($node);
}
return $innerHtml;
}
// Return an empty string if the body element is not found
return '';
}
// Example usage
$url = 'example.com';
$htmlWithinBody = getHtmlWithinBody($url);
echo $htmlWithinBody;
?>
{/source}
This is the content of the module:
{source}
<?php
function getHtmlWithinBody($url) {
// Read the URL and get the HTML content
$html = file_get_contents($url);
// Create a DOM document
$dom = new DOMDocument();
// Disable error reporting for HTML parsing
libxml_use_internal_errors(true);
// Load the HTML content into the DOM document
$dom->loadHTML($html);
// Enable error reporting again
libxml_use_internal_errors(false);
// Find the body element
$body = $dom->getElementsByTagName('body')->item(0);
// Check if the body element exists
if ($body) {
// Get the inner HTML of the body element
$innerHtml = '';
foreach ($body->childNodes as $node) {
$innerHtml .= $dom->saveHTML($node);
}
return $innerHtml;
}
// Return an empty string if the body element is not found
return '';
}
// Example usage
$url = 'example.com';
$htmlWithinBody = getHtmlWithinBody($url);
echo $htmlWithinBody;
?>
{/source}
- Jan
- Phoca Hero
- Posts: 48535
- Joined: 10 Nov 2007, 18:23
- Location: Czech Republic
- Contact:
Re: Display files in a category using the plugin
Hi, there is Phoca Download content plugin which lists the filelist in article.
https://www.phoca.cz/phocadownload-plugin
Jan
https://www.phoca.cz/phocadownload-plugin
Jan
If you find Phoca extensions useful, please support the project