HI,
my xml file is as follows
<?xml version="1.0"?>
<config>
<nav>
<home>
<label>HOME</label>
<controller>index</controller>
<action>index</action>
</home>
<aboutus>
<label>ABOUT US</label>
<controller>about-us</controller>
<action>index</action>
</aboutus>
<destination>
<label>DESTINATION</label>
<controller>destination</controller>
<action>index</action>
</destination>
</nav>
</config>
for code in my layout.phtml file
$config = new Zend_Config_Xml(APPLICATION_PATH.'/configs/clientnav.xml', 'nav');
$container = new Zend_Navigation($config);
$this->navigation()->setContainer($container);
echo $this->navigation();
i get the result
<ul class="navigation">
<li class="active">
HOME
</li>
<li>
ABOUT US
</li>
</ul>
but i want the result
<ul class="navigation">
<li class="active">
HOME
</li>
<li classs="sep"></li>
<li>
ABOUT US
</li>
</ul>
Note the separator between two list. Help me out.
If you HAVE to have the sep there and you cannot amend your CSS as #trickwallett suggested then you can query the navigation directly and then iterate over it yourself. Note that if you do this you will need to apply your own ACL rules.
$config = new Zend_Config_Xml(APPLICATION_PATH . '/configs/navigation.xml');
$container = new Zend_Navigation($config);
$pages = $this->navigation($container)->findAllById("main");
foreach ($pages as $i => $page)
{
if(!$page->getVisible())
continue;
echo $this->menu()->htmlify($page);
}
There I use findAllById() but there are many others documented here
Related
This is phtml code for getting selected category. I want to get category description. How can I get that?
<?php
$catId =2;
$objectManager = \Magento\Framework\App\ObjectManager::getInstance();
$subcategory = $objectManager->create('Magento\Catalog\Model\Category')->load($catId);
$subcats = $subcategory->getChildrenCategories();
?>
<ul>
<li> <span> All Categories </span> </li>
<?php
foreach ($subcats as $subcat) {
if ($subcat->getIsActive()) {
$subcat_url = $subcat->getUrl();
$subcat_img = "";
$placeholder_img = "/media/placeholder.png";
?>
<li>
<a href="<?php echo $subcat_url; ?>">
<?php echo $subcat->getName(); ?>
</a>
</li>
<?php
}
}
?>
</ul>
To get the Category Description, you have to load Category and after that, you can use getDescription() function.
I have made some changes in your code. Please find the new code here:
<?php
$catId =2;
$objectManager = \Magento\Framework\App\ObjectManager::getInstance();
$subcategory = $objectManager->create('Magento\Catalog\Model\Category')->load($catId);
$subcats = $subcategory->getChildrenCategories();
?>
<ul>
<li> <span> All Categories </span> </li>
<?php
foreach ($subcats as $subcat) {
if ($subcat->getIsActive()) {
$subcat = $objectManager->create('Magento\Catalog\Model\Category')->load($subcat->getId());
$subcat_url = $subcat->getUrl();
$subcat_img = "";
$placeholder_img = "/media/placeholder.png";
?>
<li>
<a href="<?php echo $subcat_url; ?>">
<?php echo $subcat->getName(); ?>
</a>
<p><?php echo $subcat->getDescription(); ?></p>
</li>
<?php
}
}
?>
</ul>
Note: In Magento 2, the direct use of ObjectManager in template files is not a good practice. Dependency injection is the recommended approach.
For more details on how to use ObjectManager and what the consequences are of using the ObjectManager directly, you can follow the link below:
https://magento.stackexchange.com/questions/117098/magento-2-to-use-or-not-to-use-the-objectmanager-directly
I am new in TYPO3, I would like to know if it is possible to transform (using typoscript) the following structure of html-css menu in TYPO3 Hmenu. It is a multilevel structure with html lists.
<ul class="nav navbar-nav">
<!-- Home -->
<li class="dropdown">
<a href="javascript:void(0);" class="dropdown-toggle" data-toggle="dropdown">
Home
</a>
<ul class="dropdown-menu">
<li>Option 1: Default Page</li>
<!-- One Page -->
<li class="dropdown-submenu">
Option 2: One Page
<ul class="dropdown-menu">
<li><a target="_blank" href="One-Pages/Classic/index.html">- One Page Template</a></li>
<li><a target="_blank" href="One-Pages/Classic/one_page_dark.html">- One Page Dark Option</a></li>
</ul>
</li>
<!-- End One Page -->
</ul>
</li>
<!-- End Home -->
<!-- Pages -->
<li class="dropdown">
<a href="javascript:void(0);" class="dropdown-toggle" data-toggle="dropdown">
Pages
</a>
<ul class="dropdown-menu">
<!-- About Pages -->
<li class="dropdown-submenu">
About Pages
<ul class="dropdown-menu">
<li>About Us </li>
<li>About Us 1</li>
</ul>
</li>
<!-- End About Pages -->
<!-- Service Pages -->
<li class="dropdown-submenu">
Service Pages
<ul class="dropdown-menu">
<li>Our Services</li>
</ul>
</li>
<!-- End Service Pages -->
</ul>
</li>
<!-- End Pages -->
</ul>
It is possible, please read the very detailed manual here.
lib.textmenu = HMENU lib.textmenu {
# We define the first level as text menu.
1 = TMENU
# We define the normal state ("NO").
1.NO = 1
1.NO.allWrap = <li>|</li>
# We define the active state ("ACT").
1.ACT = 1
1.ACT.wrapItemAndSub = <li>|</li>
# Wrap the whole first level.
1.wrap = <ul class="level1">|</ul>
# The second and third level should be configured exactly
# the same way.
# In between the curly brackets, objects can be copied.
# With the dot "." we define that the object can be found
# in the brackets.
# With 2.wrap and 3.wrap we overwrite the wrap, which was
# copied from 1.wrap.
2 < .1
2.wrap = <ul class="level2">|</ul>
3 < .1
3.wrap = <ul class="level3">|</ul>
}
If you already know TypoScript, then here are the references: HMENU, TMENU, TMENUITEM
This question is related to Access fluidpage configuration in template.
I try the same as in the question above. But as flux:flexformis outdated and replaced with flux:form there may be some changes I'm not aware of.
With the following code I try to access the flex:form.fields from the menu-items:
<v:page.menu levels="1" as="sections">
<ul class="main-navi">
<f:for each="{sections}" as="section" iteration="iteration">
<f:debug>{section}</f:debug>
<flux:form.data table="pages" field="tx_fed_page_flexform" uid="{section.uid}" as="sectionData" />
<f:debug>{sectionData}</f:debug>
<li {f:if(condition: section.active, then: ' class="active"')}>
<f:link.page pageUid="{section.uid}" title="{section.linktext}">{ section.title}</f:link.page>
<div class="testmenu"></div>
</li>
</f:for>
</ul>
</v:page.menu>
In the Debug of the section (<f:debug>{section}</f:debug>) I see the value of tx_fed_page_flexform:
tx_fed_page_flexform => '<?xml version="1.0" encoding="utf-8" standalone="
;yes" ?> <T3FlexForms> <data> <sheet inde
x="options"> <language index="lDEF">
; <field index="text"> &
lt;value index="vDEF">test1234</value> &l
t;/field> </language> </sheet> </d
ata> </T3FlexForms>' (336 chars)
The value I search is test1234.
But when I debug the sectionData (<f:debug>{sectionData}</f:debug>) I just get a NULL.
Found a solution. To set sectionData use v:variable.set. the as in flux:form.data seems not to work.
<v:variable.set name="sectionData" value="{flux:form.data(table:'pages', field:'tx_fed_page_flexform', uid:'{section.uid}')}" />
Is some way to change structure pagination tags in Laravel 4?
I am creating the pagination links using the links method:
<?php echo $data->links(); ?>
HTML is like this:
<div class="pagination">
<ul>
<li>
1
</li>
<li>
2
</li>
</ul>
</div>
For example remove unordered HTML list?
Edit app/config/view.php and change the pagination option to be one of your views, like 'pages'.
The create your pages.php view.
The default pagination is below. I'd start with that and start tweaking it as you need.
<?php
$presenter = new Illuminate\Pagination\BootstrapPresenter($paginator);
$trans = $environment->getTranslator();
?>
<?php if ($paginator->getLastPage() > 1): ?>
<ul class="pager">
<?php
echo $presenter->getPrevious($trans->trans('pagination.previous'));
echo $presenter->getNext($trans->trans('pagination.next'));
?>
</ul>
<?php endif; ?>
Hello I'm digging into this problem without finding a solution. It seems very simple but I turn around for a while.
I'm trying to highlight a parent and 1 child in a menu. Both have the same uri, but only the parent is getting the active class.
Here my xml:
<configData>
<apps>
<agenda>
<label>Agenda</label>
<uri>/apps/agenda</uri>
<pages>
<page1>
<label>Page 1</label>
<uri>/apps/agenda</uri>
</page1>
<page2>
<label>Page 2</label>
<uri>/apps/agenda/page2</uri>
</page2>
</pages>
</agenda>
</apps>
</configData>
here my .phtml:
<div>
<?php echo $this->navigation(Zend_Registry::get('Zend_NavigationApp'))->menu()
->renderMenu(null, array(
'minDepth' => null,
'maxDepth' => 1,
'ulClass' => 'navigation',
'onlyActiveBranch' => false));
?>
</div>
and here the generated html:
<div>
<ul class="navigation">
<li class="active">
Agenda
<ul>
<li> /*Here the expected active class*/
Page 1
</li>
<li>
Page 2
</li>
</ul>
</li>
</ul>
</div>
All that I want to do is to get the "li" parent and "li" child with an active class after I clicked the parent link.
Solution
Using MVC instead of URI style config xml file fixed all my problems.
Here my fixed xml:
<configData>
<apps>
<agenda>
<label>Agenda</label>
<module>module_1</module>
<controller>control_1</controller>
<action>action_1</action>
<route>agenda_1</route>
<pages>
<page1>
<label>Page 1</label>
<module>module_1</module>
<controller>control_1</controller>
<action>action_1</action>
<route>agenda_1</route>
</page1>
<page2>
<label>Page 2</label>
<module>module_2</module>
<controller>control_2</controller>
<action>action_2</action>
<route>agenda_2</route>
</page2>
</pages>
</agenda>
</apps>
</configData>
Note that I'm using route definition in my ini file.