简体   繁体   English

如何将$ _GET ['']值从mod_modulenamet / mpl / default.php中的$ document-> addStylesheet()转换为joomla模块的css.php文件

[英]How to $_GET [' '] value from $document->addStylesheet() in mod_modulenamet/mpl/default.php to css.php file of joomla module

Im trying create module for joomla 2.5 but i have error need everyone help me. 我正在尝试为joomla 2.5创建模块,但是我有错误需要所有人的帮助。 I have scripts in tmpl/default.php file: 我在tmpl / default.php文件中有脚本:

defined('_JEXEC') or die;
$baseurl = JUri::base();
$module_names="modules/mod_mymodule/assets";
$url=$baseurl.$module_names;
$module_id= $module->id;
$document = JFactory::getDocument();
$document->addStylesheet($module_names.'/css/css.css.php?module_agallery_id1='.$module_id);
$document->addStylesheet('modules/mod_mymodule/tmpl/css.css.php?module_agallery_id='.$module_id);

And in css.css.php file i want get value of "module_gallery_id" in $document->addStylesheet above. 在css.css.php文件中,我想在上面的$ document-> addStylesheet中获取“ module_gallery_id”的值。 I tried use like this in css.css.php file but i can not get module_agallery_id. 我在css.css.php文件中尝试过使用这种方法,但无法获取module_agallery_id。 please see code bellow in my css.css.php file: 请在我的css.css.php文件中查看以下代码:

  header("Content-type: text/css; charset: utf-8");
  echo $mid = $_GET['module_agallery_id']; // i can't get this

Everyone know it please let me know. 每个人都知道,请告诉我。 I'm working on joomla 2.5.x. 我正在开发joomla2.5.x。

Thank you so much and Best Regards 非常感谢和最诚挚的问候

Try this, 尝试这个,

I think you're totally confused with style sheet adding system of Joomla. 我认为您完全对Joomla的样式表添加系统感到困惑。 You can work like this way. 您可以像这样工作。 your css.css.php is a php file so why are you trying to add to the header. 您的css.css.php是一个php文件,因此为什么要尝试添加到标题中。

keep the file as php and include that to the module. 将文件保存为php并将其包含到模块中。

In your css.css.php file have the following code. 在您的css.css.php文件中,包含以下代码。

$doc = JFactory::getDocument();
echo $module_id;
//If you need to add custom css on this page try like.
$css_styles = '.my_testclass{color:#FFF;}';
$doc->addStyleDeclaration($css_tyles);

Then On your module file instead of adding style sheet include the page like below. 然后在您的模块文件上,而不是添加样式表,包括如下页面。

$module_names="modules/mod_mymodule/assets";
require_once(JPATH_SITE.'/'.$module_names.'/css/css.css.php');

Hope it helps.. 希望能帮助到你..

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM