在Joomla组件com_search中,我修改了以下行:
<?php if ($this->params->get('show_date')) echo JText::sprintf('Published %s', $result->created).'. '; ?>
自:
<?php if ($this->params->get('show_date')) echo '<span>'.JText::_('PUBLISHED').': '.'</span>'.JText::sprintf('%s', JHtml::_('date',$result->created, JText::_('d. m. Y, H:i'))); ?>
并在搜索某些内容时出现错误 500:
DateTime::__construct(): Failed to parse time string (19. 06. 2012) at position 0 (1): Unexpected character
问题出在哪里?
com_search(default_results.php)的完整代码,以便更好地理解:
<div class="items">
<?php foreach ($this->results as $result) : ?>
<article class="item">
<header>
<?php if ( $result->href ) : ?>
<h1 class="title"><a href="<?php echo JRoute::_($result->href); ?>" <?php if ($result->browsernav == 1 ) echo 'target="_blank"'; ?>><?php echo $this->escape($result->title); ?></a></h1>
<?php else : ?>
<h1 class="title"><?php echo $this->escape($result->title); ?></h1>
<?php endif; ?>
<?php if ($result->section || $this->params->get('show_date')) : ?>
<p class="meta">
<?php if ($this->params->get('show_date')) echo '<span>'.JText::_('PUBLISHED').': '.'</span>'.JText::sprintf('%s', JHtml::_('date',$result->created, JText::_('d. m. Y, H:i'))); ?>
<?php if ($result->section) echo JText::_('TPL_WARP_POSTED_IN').' '.$this->escape($result->section); ?>
</p>
<?php endif; ?>
</header>
<div class="content clearfix"><?php echo $result->text; ?></div>
</article>
<?php endforeach; ?>
</div>
<?php echo $this->pagination->getPagesLinks(); ?>
日期时间::__construct(): 无法解析时间字符串 (19.06. 2012) 在位置 0 (1):意外角色
19. 06. 2012
不是 PHP 的 DateTime
类接受的日期格式,请参阅 PHP 手册页"日期格式"以获取理解的格式列表。
我刚刚将您的新行复制并粘贴到 Joomla 2.5.6 的本地托管副本中,它工作绝对正常 - 完全没有错误!
在Joomla中,当尝试安装任何类型的扩展时,也会发生此错误,但PHP代码无法写入临时和日志目录。
如果转到"系统"、"系统信息"和"目录"权限,则所有内容都是可写的。可以在配置中更改临时和日志目录的路径.php也可以使用"全局配置"菜单和"系统和服务器"选项卡进行更改。
在谷歌上花了四个小时解决这个问题后,事实证明我的原因是不可写的/logs
和/tmp
文件夹。
若要验证,请执行以下步骤:
- 加载以下 URL(替换您自己的域和主机名):
http://www.example.com/administrator/index.php?option=com_admin&view=sysinfo
- 导航到"所有者权限"
- 检查
logs
和tmp
是否可写 - 如果没有,则应在 config.php 文件中更改这些文件的路径。
以下是Joomla论坛主题的相关引述,帮助我得出了这个结论:
您好,我最近遇到了同样的问题,但找到了诀窍!
日志目录 ($log_path) ./logs/不可写
Temp Directory ($tmp_path) ./tmp/Unwriteitable正确的目录路径必须是:
日志目录 ($log_path) ../原木/
日志目录 ($log_path) ../.tmp/