I try to use dropdowns of bootstrap, it's work the problem is esthetic. :
http://twitter.github.io/bootstrap/javascript.html#dropdowns
I have this code :
<div class="dropdown">
<a class="dropdown-toggle" data-toggle="dropdown" href="#">Colléctivités <b class="caret"></b></a>
<ul class="dropdown-menu" role="menu" aria-labelledby="dLabel">
<?php
foreach ($collectivite as $key => $value) {
echo '<form method="post" action="wbx.php"><li><button type="submit" class="btn" style="margin:0px;" name="cookie" value='.$value.'>'.$value.'</button> </li></form>';
}
?>
</ul>
</div>
WITHOUT PHP :
<div class="dropdown">
<a class="dropdown-toggle" data-toggle="dropdown" href="#">Colléctivités <b class="caret"></b></a>
<ul class="dropdown-menu" role="menu" aria-labelledby="dLabel">
<form method="post" action="wbx.php">
<li>
<button type="submit" class="btn" style="margin:0px;" name="cookie" value=heeloWorld.net>world.net</button>
</li>
</form>
</ul>
</div>
But the result is very basic... not really good. I use button because i submit some data with form
So if i want something like this, how can i do ?
EDIT solution
I Use this : the alert is ok, i have the good value, but the submit doesn't work.
<?php
foreach ($collectivite as $key => $value) {
$name = preg_replace('#[^0-9a-z]+#i', '', $value);
echo '<form method="post" action="wbx.php" id='.$name.'>
<input type="hidden" name="cookie" value='.$value.'>
</form>';
}
?>
<div class="dropdown">
<a class="dropdown-toggle" data-toggle="dropdown" href="#">Colléctivités <b class="caret"></b></a>
<ul class="dropdown-menu" role="menu" aria-labelledby="dLabel">
<?php
foreach ($collectivite as $key => $value) {
$name = preg_replace('#[^0-9a-z]+#i', '', $value);
echo '<li>
<input type="hidden" name="cookie" value='.$value.'>
<a class="myformlink" data-formname="#'.$name.'" >'.$value.'</a>
</li>';
}
?>
</ul>
</div>
<script type="text/javascript">
$(document).ready(function() {
$('.myformlink').click(function(){
$($(this).data('formname')).submit();
});
});
</script>
You do not have to use a button tu submit your form. You can use a regular anchor to do it. please check this link : i want a anchor should act like and input type submit button
this way your dropdown will look like the one in your example.
Hope it helps :)
Edit : In French we write "Collectivités" ;) just kiddin...
EDIT : sample of a code with data attributes
<div class="dropdown">
<a class="dropdown-toggle" data-toggle="dropdown" href="#">Colléctivités <b class="caret"></b></a>
<ul class="dropdown-menu" role="menu" aria-labelledby="dLabel">
<form method="post" action="wbx.php" id="formGujanMestras">
<li>
<a class="myformlink" id="linkC" data-formname="#formGujanMestras">value1</a>
</li>
</form>
<form method="post" action="wbx.php" id="formLaHume">
<li>
<a class="myformlink" id="linkD" data-formname="#formLaHume">value2</a>
</li>
</form>
</ul>
</div>
<script type="text/javascript">
$(document).ready(function() {
$('.myformlink').click(function(){
alert('hey martial i gonna submit ' + $(this).data('formname'));
$($(this).data('formname')).submit();
});
});
</script>
Related
friends, I want to turn the datepicker on and off in both input and icon clicks in this code structure, but I couldn't succeed, can you help?
<div class="container">
<div class="col-sm-6" style="height:130px;">
<div class="form-group">
<div class='input-group datetimepicker'>
<input type='text' class="form-control" />
<span class="input-group-addon">
<span class="glyphicon glyphicon-calendar">
</span>
</span>
</div>
</div>
</div>
<script type="text/javascript">
$(function () {
$('.datetimepicker').datetimepicker({
viewMode: 'years'
});
});
</script>
</div>
I want to display only those pages in the header which have child pages inside them. Using the following code
<nav class="wsmenu clearfix" data-sly-use.nav="in.gov.odishatourism.core.models.HeaderNavigation">
<ul class="wsmenu-list" >
<li aria-haspopup="true" data-sly-repeat="${nav.root.listChildren}" ><span class="wsmenu-click" ><i class="wsmenu-arrow fa fa-angle-down"></i></span>
<a class="" href="javascript:void(0);" data-sly-test="!${item.hasChild}">${item.title}</a>
<div class="wsmegamenu clearfix ">
<div class="container paddingmenu">
<div class="row">
<div class="menuimgdiv" data-sly-repeat.subcategory="${item.listChildren}">
<h3 class="title" data-sly-test.subcat="${subcategory.title}" >${subcat}</h3>
<ul>
<li data-sly-repeat.page="${subcategory.listChildren}"><a class="" href="${page.path # extension='html'}">${page.title}</a></li>
</ul>
</div>
</div>
</div>
</div>
</li>
<li aria-haspopup="true"> Dept of Tourism</li>
</ul>
<a class="wsdownmenu-animated-arrow"><span></span></a>
<div class="wsdownmenu-text">Navigation</div>
</nav>
gives the following output
But this code -
<nav class="wsmenu clearfix" data-sly-use.nav="in.gov.odishatourism.core.models.HeaderNavigation">
<ul class="wsmenu-list" >
<li aria-haspopup="true" data-sly-repeat="${nav.root.listChildren}" ><span class="wsmenu-click" ><i class="wsmenu-arrow fa fa-angle-down"></i></span>
<a class="" href="javascript:void(0);" data-sly-test="${item.hasChild}">${item.title}</a>
<div class="wsmegamenu clearfix ">
<div class="container paddingmenu">
<div class="row">
<div class="menuimgdiv" data-sly-repeat.subcategory="${item.listChildren}">
<h3 class="title" data-sly-test.subcat="${subcategory.title}" >${subcat}</h3>
<ul>
<li data-sly-repeat.page="${subcategory.listChildren}"><a class="" href="${page.path # extension='html'}">${page.title}</a></li>
</ul>
</div>
</div>
</div>
</div>
</li>
<li aria-haspopup="true"> Dept of Tourism</li>
</ul>
<a class="wsdownmenu-animated-arrow"><span></span></a>
<div class="wsdownmenu-text">Navigation</div>
</nav>
gives the output as shown below
The code
<a class="" href="javascript:void(0);" data-sly-test="${item.hasChild}">${item.title}</a>
is not working properly.
My site structure is as shown below
And the actual desired output is
You cannot use ${item.hasChild} in your test condition as the hasChild() method of the Page API requires you to pass a parameter. AFAIK, HTL doesn't support invocation of parameterized methods.
Since there is no direct API available to check if a page has child pages or not, you may need to do the following to validate if the page has child pages
<a class="" href="javascript:void(0);" data-sly-test="${item.listChildren && item.listChildren.hasNext}">${item.title}</a>
However, I would prefer building the entire navigation tree using Sling models or WCM Use API and not invoking so many methods in the HTL. That would make the code easier to maintain, change and test. YMMV
I have a website built in php codeigntier framework.
I have index page that's dynamically loading "li" elements and each "li" element has "a" tag which should display some item information via fancybox. Sometimes it is working, but sometimes it opens fancybox window, but instead of content it shows : "The requested content cannot be loaded message on some items".
Here is the code and after it i will explain what i did here:
index.php view (display page)
<li class="col-1-3">
<h3>
<?=$itm['name'];?>
</h3>
<figure class="full-width">
<a id="inline" href="#data-<?=$itm['code']?>" class="inset-border zoom-hover" data-zoom-hover-title="Detalji">
<img src="/slike/<?php echo $itm['img_name']?>" data-2x="/slike/<?php echo $itm['img_name']?>" width="124" height="150" alt="" />
</a>
</figure>
<p>
<b>Cena</b>: <?=$itm['price'];?> <br/>
<b>Sifra</b>: <?=$itm['code'];?><br/>
<b>PDV</b>: 19%
</p>
<b>Kolicina</b>: <input type="qty" class="qty-<?php echo $itm['id'];?>" name="qty" onkeypress="return isNumberKey(event)" size="3" maxlength="3"/>
<?php if($is_logged){?>
<p>
<a href="#_" class="buyButton big" name="<?php echo $itm['name'] ?>" id="<?php echo $itm['id'];?>" >
<span>Dodaj</span>
<i class="icon-plus color-blue"></i>
</a>
</p>
<?php }else{ ?>
<p>
<a id="loged" href="$_" class="infoButton big">
<span>Info</span>
<i class="icon-info"></i>
</a>
</p>
<?php } ?>
<div style="display:none">
<div id="data-<?=$itm['code']?>">
<figure id="images" class="alignleft">
<img src="/slike/<?php echo $itm['img_name']?>" data-2x="/slike/<?php echo $itm['img_name']?>" width="250" height="350" alt="" />
</figure>
<h3><?=$itm['name']?></h3>
<p><b>Cena Artikla: </b> <?=$itm['price']?> RSD<br/>
<b>Opis artikla: </b><?=$itm['descr'];?></p>
</div>
</div>
<!--<div style="display:none">
<div id="log">
<p>Morate biti ulogovani da bi ste kupili artikal</p>
</div>
</div>-->
</li>
So, dynamically adss data- ITEMID to every li item, and below
<div style="display:none">
<div id="data-<?=$itm['code']?>">
<figure id="images" class="alignleft">
<img src="/slike/<?php echo $itm['img_name']?>" data-2x="/slike/<?php echo $itm['img_name']?>" width="250" height="350" alt="" />
</figure>
<h3><?=$itm['name']?></h3>
<p><b>Cena Artikla: </b> <?=$itm['price']?> RSD<br/>
<b>Opis artikla: </b><?=$itm['descr'];?></p>
</div>
</div>
has same ITEMID dynamically added.
So, by clicking on that , hidden info should display in fancybox... and it is working, sometimes.. sometimes not...
Here is my js file:
$("a#inline").fancybox({
'hideOnContentClick': true
});
which is, of course, included in header of page, as fancybox.js file...
Any one has solution or suggestion ?
Thanks in advance.
p.s. you can visit poljoprivrednaapoteka.com and see the problem, just try clicking on few items, and the problem will pop..
i am again posting this question as i was unable to do what i wanted to, and also didn't get the answer of my previous question. Hope, this time it will catch the eye of someone who can answer.
I have created a module which enables to submit a form in the backend just like news module and faqs module etc and shows the result in the grid.
But what i want now is that i must be able to save the form frontend and show the results in grid.
i was told that it can be done through indexcontroller.php of my module. So what i actually did was i copied the save action of adminhtml controller and try to use it in index controller.
public function postAction() {
if ($data = $this->getRequest()->getPost()) {
$model = Mage::getModel('events/events');
$model->setData($data)
->setId($this->getRequest()->getParam('id'));
try {
if ($model->getCreatedTime == NULL || $model->getUpdateTime() == NULL) {
$model->setCreatedTime(now())
->setUpdateTime(now());
} else {
$model->setUpdateTime(now());
}
$model->save();
Mage::getSingleton('core/session')->addSuccess(Mage::helper('events')->__('Item was successfully saved'));
Mage::getSingleton('core/session')->setFormData(false);
if ($this->getRequest()->getParam('back')) {
$this->_redirect('*/*/edit', array('id' => $model->getId()));
return;
}
$this->_redirect('*/*/');
return;
} catch (Exception $e) {
Mage::getSingleton('core/session')->addError($e->getMessage());
Mage::getSingleton('core/session')->setFormData($data);
$this->_redirect('*/*/edit', array('id' => $this->getRequest()->getParam('id')));
return;
}
}
Mage::getSingleton('core/session')->addError(Mage::helper('events')->__('Unable to find item to save'));
$this->_redirect('*/*/');
}
/* testing */
and in frontend i created a phtml file :
<div id="messages_product_view"><?php echo $this->getMessagesBlock()->getGroupedHtml() ?></div>
<form action="<?php echo $this->getPostActionUrl(); ?>" method="post" enctype="multipart/form-data" id="events_form">
<div class="fieldset">
<ul class="form-list">
<li>
<label for="title"><em>*</em><?php echo Mage::helper('events')->__('Title:') ?></label>
<div class="input-box">
<input style="font-size:14px;" name="title" id="content" value="" class="input-text required-entry" type="text" size="29"/>
</div>
</li>
<li class="wide">
<label for="content" class="required"><em>*</em><?php echo Mage::helper('events')->__('Description:') ?></label>
<div class="input-box">
<textarea name="content" id="content" title="<?php echo Mage::helper('events')->__('Description') ?>" class="input-text required-entry" style="font-size:14px;" name="overview" cols="55" rows="30"></textarea>
</div>
</li>
</ul>
</div>
<div class="buttons-set">
<p class="required"><?php echo Mage::helper('events')->__('* Required Fields') ?></p>
<input type="text" name="hideit" id="hideit" value="" style="display:none !important;" />
<button type="submit" title="<?php echo Mage::helper('events')->__('Submit') ?>" class="button"><span><span><?php echo Mage::helper('events')->__('Submit') ?></span></span></button>
</div>
</form>
<script type="text/javascript">
//<![CDATA[
var eventsForm = new VarienForm('events_form', true);
//]]>
</script>
But no luck :( can anyone please tell me how to get it done.
This is my accordion menu :
<script type="text/javascript">
$(function()
{
$("dt.title").click(function()
{ $("div.info").slideUp("slow"); $(this).next("div.info:hidden").slideDown("normal" );
});
});
</script>
It is working fine, here have a look at the html:
<body>
<div id="wrapper">
<div id="container">
<ul id="nav">
<dt class="title">About</dt>
<dt class="title">Work</dt>
<div class="info">
<ul>
<li>Bol</li>
<li>Annie</li>
<li>Imran</li>
</ul>
</div>
<dt class="title">Contact</dt>
<dt class="title">Links</dt>
</ul>
</div>
<div id="content">
</div>
</div>
</body>
</html>
Very simple ! But when I put the href links, the menu stop working. For example:
<dt class="title">About</dt>
Please help me with this, I'll be really thankful !
Cheers,