hello so i'm trying to make a menu with css but when i try to click on an element from the menu it opens it in a new tab while i want it inside a div in the same page i'm new in css and thats my homework can you help me please and thanks
this is the code
<div id="menu"><?php include('admin/Menu/menu.php');?></div>
<div id="main">
i want the content here
</div>
this is the menu code
<ul id="menu">
<li>
Catalogue
<ul>
<li>Produits</li>
<li>Catégories</li>
<li>Marque</li>
<li>Fournisseur</li>
</ul>
</li>
<li>
Commandes
<ul>
<li>Commandes</li>
<li>Messages prédifinis</li>
</ul>
</li>
<li>
Clients
<ul>
<li>Clients <li>
<li>Pays</li>
<li>Groupes <li>
<li>Titre de civilité</li>
</ul>
</li>
<li>
Paramètres avancés
<ul>
<li>Emails</li>
<li>Images</li>
</ul>
</li>
<li>
Administration
<ul>
<li>Employés</li>
<li>Profils</li>
<li>Permission</li>
</ul>
</li>
<li>
Stats
<ul>
<li>Stats</li>
</ul>
</li>
What you could do is either something like this:
<a id='showMeButton'>button</a>
<a id='showThisButton'>button2</a>
<div id='main'>
<div id='showMeContent' class='content'>
<p>This is just some basic content</p>
</div>
<div id='showThisContent' class='content'>
<p>This is also just some basic content</p>
</div>
</div>
<style>
.content { display: none; }
#showMeButton:active #showMeContent { display: block; }
#showThisButton:active #showThisContent { display: block; }
</style>
This is the closest you can get using css, but you might be able to do this a little better by using jQuery:
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"></script>
<a id='showMeButton'>button</a>
<a id='showThisButton'>button2</a>
<div id='main'></div>
<script>
$('#showMeButton').click(function() {
$("#main").empty();
$("#main").append("<p>This is some content</p>");
});
$('#showThisButton').click(function() {
$("#main").empty();
$("#main").append("<p>This is also some content</p>");
});
</script>
Whatever you do, you dó have to make sure you start using id tags, otherwise it just acts as a link, you can easily replace the href='#' with id='something', and then write some css or javascript which opens your content inside the div you'd like it in.
Related
I'm hoping somebody with more experience using timber can help me? I'm trying to create a Wordpress theme using timber/ twig and I want to be able to include yelp reviews in the footer on every page within the site.
I've got the following files:
sidebar.twig
<!-- Review and contact button Section -->
{% if sidebar %}
<section class="reviewSection">
<div class="review__container">
{{sidebar.text}}
</div>
</section>
{% endif %}
footer.twig
{% include('templates/_embeds/_sidebar.twig') %}
<!-- Footer -->
<footer>
{# <div class="footer__contact">
<div class="FooterCTABox">
<a class="cta--contact FooterCTA"href="{{site.url.path}}/contact">Book Now</a>
<a class="cta--phone FooterCTA"href="tel:080979767645">Call Us</a>
</div>
</div> #}
<div class="footer__main">
<div class="main__container">
<div class="main__addressCol footerCol">
<h4>Get in touch</h4>
<div class="footerCol__content footerCol__content--address">
<p><span>1 Address Blvd<br />place<br />San Diego<br />Zipcode</span><br /><span class="address__contact"tel: 0880009123123</span><br /><span class="address__contact"email: info#email.com</span></p>
</div>
</div>
<div class="main__linkCol footerCol">
<h4>Links</h4>
<div class="footerCol__content">
<ul>
<li>FAQS</li>
<li>Blog</li>
<li>Gallery</li>
<li>Events</li>
<li>Contact</li>
</ul>
</div>
</div>
<div class="main__socialCol footerCol">
<h4>Follow us</h4>
<div class="footerCol__content footerCol__content--social">
<ul>
<li>Facebook</li>
<a href="<li>Instagram</li></a>
<li>Yelp</li>
</ul>
</div>
</div>
<div class="main__logoCol footerCol">
<picture>
<img src="{{site.theme.path}}/images/logo-text-sm.png" alt="Logo" />
</picture>
</div>
</div>
</div>
<div class="footer__end">
<div class="end__links">
<ul>
<li class="end__date">{{ "now"|date("Y") }} © {{ site.name }}</li>
<li>Terms & Conditions</li>
<li class="web">Website Designed & managed by - Web Design</li>
<ul>
</div>
</div>
</footer>
<script type="text/javascript" src="{{site.theme.path}}/scripts/script.js"></script>
</body>
</html>
sidebar.php
<?php
/* sidebar.php */
$context = array();
$context['sidebar'] = Timber::get_sidebar('Primary Sidebar');
Timber::render('/templates/_embeds/_sidebar.twig', $context);
sidebar.scss
.reviewSection {
background-color: #fff;
height: auto;
min-height: 200px;
#include flex(center, center, row);
#media (max-width: $mobileScreen) {
margin-top: 30px;
}
.review__container {
margin: auto;
width: 70%;
height: 25%;
min-height: 150px;
background-color: #d32323; // to be removed once the actual yelp plugin is in there.
#include flex(center, center, row);
h3 {
color: $textPrimary;
}
#media (max-width: $tabletScreen) {
width: 90%;
margin: 0;
}
}
}
And within Wordpress I've created a widget that is currently using the Yelp review plugin.
The issue I'm getting is that when I run the code, the sidebar HTML shows, but not the actual sidebar content from the plugin. I just get the big red placeholder box with no content. I've also included the sidebar screenshot from Wordpress itself in case that's useful and I've done something wrong there.
Would be very grateful for any help anyone has. I've tried searching for a few days to get the answer and I'm just not sure what's going wrong.
Many thanks
You don't need sidebar.php (since you're loading it via twig already) and you need to load sidebar content into context globally to be loaded whenever you need it.
Move this line:
$context['sidebar'] = Timber::get_sidebar('Primary Sidebar');
Same as the menu here: https://timber.github.io/docs/guides/menus/#setting-up-a-menu-globally
They are other ways around but I like the top one best. But if you want to have a look on multiple options go and check the official documentation for sidebars.
I am having trouble including a php file with my navigation bar in another php file.
Here's the navigation file:
<?php echo "
<html>
<head>
<nav class = "navbar navbar-default navbar-fixed-top " role = "navigation">
<div class = "container-fluid">
<div class = "navbar-header navbar-right">
<ul class = "nav navbar-nav">
<li> About Me </li>
<li> Contacts </li>
<li> Skills </li>
<li> Portfolio </li>
<li> Case Studies</li>
<li> Resume </li>
<li> Extras</li>
</ul>
</div>
</div>
</nav>
</head>
<script src = "js/bootstrap.min.js"></script>
<script src = "js/jquery.min.js"></script>
</html>
" ?>
I have this line in my index.php file
<?php
include"navigation.php";
?>
I have checked the referencing of the file and all refereces seem ok.
" should be '
<?php echo '
<html>
<head>
<nav class = "navbar navbar-default navbar-fixed-top " role = "navigation">
<div class = "container-fluid">
<div class = "navbar-header navbar-right">
<ul class = "nav navbar-nav">
<li> About Me </li>
<li> Contacts </li>
<li> Skills </li>
<li> Portfolio </li>
<li> Case Studies</li>
<li> Resume </li>
<li> Extras</li>
</ul>
</div>
</div>
</nav>
</head>
<script src = "js/bootstrap.min.js"></script>
<script src = "js/jquery.min.js"></script>
</html>
';?>
include the file
<?php
include 'navigation.php';
?>
Why are you closing the HTML tag within your navigation file?
It's probably best having a 'master' application template, which you include the html tag, the head and the body, then inside the body include your scripts at the bottom and include your navigation bar using the PHP tag.
<?php try{
if( !file_exists("navigation.php") )
{ throw new Exception("Unable to include resources header"); }
else{ require_once("navigation.php"); }
}catch(Exception $e){
echo $e->getMessage();
exit;
}
?>
Please try this this will definitely work.This is working in my case.
This is my Menu items .
<html>
<body>
<div class="container">
<ul class="nav navbar-nav ct-navbar--fadeIn">
<li class="active">
HEM
</li>
<li>OM OSS</li>
<li>Vilkor</li>
<li>Nyheter</li>
<li>KONTAKTA OSS</li>
</ul>
<div class="clear"></div>
</div>
</body>
</html>
Curently it reamains active on home page even changing to other page. How could i able to make it active of that page on every page changing.
Thanks in advance.
try this
<?php
$myactiveli = $_GET['con'];
?>
<html>
<body>
<div class="container">
<ul class="nav navbar-nav ct-navbar--fadeIn">
<li <?php if($myactiveli==1) { echo 'class="active"'; } ?> >
HEM
</li>
<li <?php if($myactiveli==3) { echo 'class="active"'; } ?>>OM OSS</li>
</ul>
<div class="clear"></div>
</div>
</body>
</html>
u can change index of <li> in .eq() according to page (starts from 0) the active class will aply to that index <li>
<!DOCTYPE html>
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.2/jquery.min.js"></script>
<script>
$(document).ready(function(){
$(".nav").children("li").eq(2).addClass("active");
});
</script>
</head>
<body>
<div class="container">
<ul class="nav navbar-nav ct-navbar--fadeIn">
<li>
HEM
</li>
<li>OM OSS</li>
<li>Vilkor</li>
<li>Nyheter</li>
<li>KONTAKTA OSS</li>
</ul>
<div class="clear"></div>
</div>
</body>
</html>
This jQuery work too for me.
<script>
var url = window.location;
// Will only work if string in href matches with location
$('ul.nav a[href="' + url + '"]').parent().addClass('active');
// Will also work for relative and absolute hrefs
$('ul.nav a').filter(function() {
return this.href == url;
}).parent().addClass('active');
</script>
while($recor1=mysql_fetch_assoc($res1))
{
?>
<ul>
<li class="col-md-3 col-sm-3"><div class="dest-list"><?php echo $recor1['sub_destination']; ?></div> </li>
</ul>
<div class="clearfix"></div>
<?php
}
it displays the result horizontally i want it vertically please give me soluation
there are a number of things wrong with your code, why are you adding a new list for every item with only one list item, that makes no sense. Also do not add block elements inside inline elements (div inside a). Also if you what the list items under each other then why add the col-... class?
<ul>
<?php while($recor1=mysql_fetch_assoc($res1)) {?>
<li class="">
<a href="#">
<?php echo $recor1['sub_destination']; ?>
</a>
</li>
<?php } ?>
</ul>
this gives you the right html structure, and you can then style it as you see fit
if you dont want to display a list horizontally remove col-sm-3 class of your li, which changes your code like below
while($recor1=mysql_fetch_assoc($res1)) { ?>
<div class="col-md-3 col-sm-3">
<ul>
<li >
<a href="#">
<div class="dest-list">
<?php echo $recor1['sub_destination']; ?>
</div>
</a>
</li>
</ul>
</div>
<div class="clearfix"></div>
<?php
}
take a look at this example
I have 3 columns in my app. Each column has an unordered list. I am using Nestable to drag and drop list items between lists. The mark up is as follows:
<div class="row-fluid span12">
<div class="cf nestable-lists">
<div id="pjax-content">
<div class="span4">
<div class="dd" id="nestable1">
<ul class="dd-list">
<li class="dd-item dd3-item" data-id="123">
<div class="dd-handle dd3-handle">Drag</div>
<div class="dd3-content">
// list content
</div>
</li>
<li class="dd-item dd3-item" data-id="456">
<div class="dd-handle dd3-handle">Drag</div>
<div class="dd3-content">
// list content
</div>
</li>
</ul>
</div>
</div>
<div class="span4">
<div class="dd" id="nestable2">
<ul class="dd-list">
<li class="dd-item dd3-item" data-id="789">
<div class="dd-handle dd3-handle">Drag</div>
<div class="dd3-content">
// list content
</div>
</li>
<li class="dd-item dd3-item" data-id="1011">
<div class="dd-handle dd3-handle">Drag</div>
<div class="dd3-content">
// list content
</div>
</li>
</ul>
</div>
</div>
<div class="span4">
<div class="dd" id="nestable3">
<ul class="dd-list">
<li class="dd-item dd3-item" data-id="1213">
<div class="dd-handle dd3-handle">Drag</div>
<div class="dd3-content">
// list content
</div>
</li>
<li class="dd-item dd3-item" data-id="1415">
<div class="dd-handle dd3-handle">Drag</div>
<div class="dd3-content">
// list content
</div>
</li>
</ul>
</div>
</div>
</div>
</div>
</div>
This works and I can drag and drop list items between each list. The problem is when I implement PJAX.
I have a few links that use PJAX to change the url i.e. each link will update the data or order of the data in each list based on the URL. The data updates within id="pjax-content" accordingly, so it works. This is a snippet of the server side code (using CI):
if (isset($_SERVER["HTTP_X_PJAX"])) {
echo $data['contents'];
} else {
// construct views when not PJAX
}
$data['contents'] contains the html as a string.
I have the following JS libraries too (I have tried removing some of these and the problem still exists):
<script type="text/javascript" src="jquery-1.9.0.js"></script>
<script type="text/javascript" src="bootstrap.js"></script>
<script type="text/javascript" src="nestable.js"></script>
<script type="text/javascript" src="nestable-settings.js"></script>
<script type="text/javascript" src="bootstrap-editable.js"></script>
<script type="text/javascript" src="jquery.cookie.js"></script>
<script type="text/javascript" src='jquery.pjax.js'></script>
<script type="text/javascript">
$(document).pjax('[data-pjax] a, a[data-pjax]', '#pjax-content');
$(document).on('pjax:send', function() {
console.log("before send");
});
$(document).on('pjax:complete', function() {
console.log("done!");
});
</script>
The Problem
When I click on one of the links PJAX works, the data is updated, the page doesn't reload and the console shows before send and done - so all is well. However, the nestable items are no longer selectable so a I can't drag and drop them. When I do a full page refresh it works and I can drag and drop.
I have compared the markup before and after (as that was a previous issue) and everything is the same.
Any suggestions on where I am going wrong? Or how to best debug this?
call nestable after your ajax complete function
$(document).on('pjax:complete', function() {
$('#nestable1,#nestable2,#nestable3').nestable();
});