如何在joomla网站中获取身体内容 [英] how to get body content in joomla site
问题描述
我正在尝试在Joomla网站页面中找到所有图像.我计划使用以下代码:
I'm trying to find all the images in a Joomla site page. I plan to use the following code:
preg_match('/<img.+src=[\'"]([^\'"]+)[\'"].*>/i', $pageBody, $imageArray);
我相信,如果我能够将页面的<body>
内容分配给变量$pageBody
,那么上面的代码将起作用.但是我找不到正确的方法.
I believe that the above code would work if I was able to assign the <body>
content of the page to the variable $pageBody
. But I can't find the right method to do it.
我找到了JApplicationWeb
和JApplicationSite
,但是我做不到.
I've found JApplicationWeb
and JApplicationSite
but I wasn't able to do it.
我正在使用Joomla 3.7.4.
I'm using Joomla 3.7.4.
推荐答案
似乎您正在寻找系统类型插件的onAfterRender
事件.
It seems you are looking for onAfterRender
event of system type plugin.
您应该创建一个插件并添加上述事件.这将类似于下面的方法.
You should create a plugin and add above event. This would be something similar to below approach.
class plgSystemCustomplugin extends JPlugin
{
/**
*
* @return boolean
* @throws Exception
*/
public function onAfterRender()
{
$app = JFactory::getApplication();
$sHtml = $app->getBody();
// Modify $sHtml
// Set body back
$app->setBody($sHtml);
}
}
这篇关于如何在joomla网站中获取身体内容的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!