PHP 함수에서 데이터를 가져 오는 방법은 무엇입니까? 아이콘으로 전화하고 싶습니다.PHP 함수에서 데이터 가져 오기
<i class="<?php $this->Html->_($value['icon']);?>"></i>
작동하지 않습니다.
가이
<i class="fa fa-cloud"></i>
처럼 그러나 호출하면 다른 함수와 같은 것입니다 작동하는 경우 :
<a href="#"><?php $this->Html->_($value['name']); ?></a>
일 잘.
홈페이지 PHP 함수 :
/**
* Retrieves the primary navigation for the client interface
*
* @param string $base_uri The base_uri for the currently logged in user
* @return array An array of main navigation elements in key/value pairs
* where each key is the URI and each value is an array representing that element including:
* - name The name of the link
* - active True if the element is active
* - sub An array of subnav elements (optional) following the same indexes as above
*/
public function getPrimaryClient($base_uri)
{
$nav = [
$base_uri => [
'name' => $this->_('Navigation.getprimaryclient.nav_dashboard'),
'active' => false
],
$base_uri . 'accounts/' => [
'name' => $this->_('Navigation.getprimaryclient.nav_paymentaccounts'),
'active' => false,
'secondary' => [
$base_uri . 'accounts/' => [
'name' => $this->_('Navigation.getprimaryclient.nav_paymentaccounts'),
'active' => false,
'icon' => 'fa fa-list'
],
$base_uri . 'accounts/add/' => [
'name' => $this->_('Navigation.getprimaryclient.nav_paymentaccounts_add'),
'active' => false,
'icon' => 'fa fa-plus-square'
],
$base_uri => [
'name' => $this->_('Navigation.getprimaryclient.nav_return'),
'active' => false,
'icon' => 'fa fa-arrow-left'
]
]
],
$base_uri . 'contacts/' => [
'name' => $this->_('Navigation.getprimaryclient.nav_contacts'),
'active' => false,
'secondary' => [
$base_uri . 'contacts/' => [
'name' => $this->_('Navigation.getprimaryclient.nav_contacts'),
'active' => false,
'icon' => 'fa fa-list'
],
$base_uri . 'contacts/add/' => [
'name' => $this->_('Navigation.getprimaryclient.nav_contacts_add'),
'active' => false,
'icon' => 'fa fa-plus-square'
],
$base_uri => [
'name' => $this->_('Navigation.getprimaryclient.nav_return'),
'active' => false,
'icon' => 'fa fa-arrow-left'
]
]
]
];
// Include the primary client's plugin navigation
return $this->getPluginNavPrimaryClient($nav, $base_uri);
}
내가 아이콘 받기 을 표시 //로 내가 여기에 아이콘을 호출 할
<?php
$active_nav = null;
?>
<ul class="nav navbar-nav">
<?php
foreach ($this->Html->ifSet($nav, array()) as $link => $value) {
$attributes = array();
$link_attributes = array();
$dropdown = !empty($value['sub']);
$active = false;
if ($value['active']) {
$active = true;
$attributes['class'][] = "active";
$active_nav = $value;
}
if ($dropdown) {
$attributes['class'][] = "dropdown";
$link_attributes['class'][] = "dropdown-toggle";
$link_attributes['data-toggle'][] = "dropdown";
// Set parent to active if child is
if (!$active) {
foreach ($this->Html->ifSet($value['sub'], array()) as $sub_link => $sub_value) {
if ($sub_value['active']) {
$attributes['class'][] = "active";
break;
}
}
}
}
?>
<li<?php echo $this->Html->buildAttributes($attributes);?>>
<a href="<?php $this->Html->_($link);?>"<?php echo $this->Html->buildAttributes($link_attributes);?>>
// Get Icon
<i class="<?php $this->Html->_($value['icon']);?>"></i>
// Get Icon
<?php
$this->Html->_($value['name']);
if ($dropdown) {
?>
<b class="caret"></b>
<?php
}
?>
</a>
<?php
if (!empty($value['sub'])) {
?>
<ul class="dropdown-menu">
<?php
foreach ($this->Html->ifSet($value['sub'], array()) as $sub_link => $sub_value) {
?>
<li>
<a href="<?php $this->Html->_($sub_link);?>"><i class="<?php $this->Html->_($sub_value['icon']);?>"></i> <?php $this->Html->_($sub_value['name']);?></a>
</li>
<?php
}
?>
</ul>
<?php
}
?>
</li>
<?php
}
?>
</ul>
사람이 이것에 대한 어떤 아이디어가 있었나요?
정말 감사합니다. 이름 속성이 있기 때문에
프런트 엔드에서 php를 호출 할 수 없습니다. 백 엔드로 이동하려면 AJAX 호출을 설정해야합니다. PHP는 클라이언트 컴퓨터가 아닌 웹 서버에서 실행됩니다. – Daniel
PHP 메이트에 새롭게 등장한 –
PHP에 오신 것을 환영합니다 .--). 나는 당신의 질문을 잘못 읽었습니다. – Daniel