I want to add tab id to the URL and also want to activate the current tab which tab id in the URL.
If I hit the URL with tab id from another system then the same tab will be active.
I have the added my code:
<div id="faq-accordion">
<ul class="tabs">
<li class="tab-link current" data-tab="tab-1"><a href="#tab-2">About us</li>
<li class="tab-link" data-tab="tab-2"><a href="#tab-2">Ordering</li>
<li class="tab-link" data-tab="tab-3"><a href="#tab-2">Payment</li>
</ul>
<div id="tab-1" class="tab-content current">
<div class="accordion-block close">
<div class="accordion-trigger close">
<span>Can order be placed on phone?</span>
</div>
<div class="accordion-content">
<ul>
<li>Yes, we do take orders on the phone</li>
<li>We also take orders via Whatsapp. </li>
</ul>
</div>
</div>
</div>
<div id="tab-2" class="tab-content">
<div class="accordion-block close">
<div class="accordion-trigger close">
<span>Only Part of my order has arrived. Why?</span>
</div>
<div class="accordion-content">
<p>In rare occasions, few of the ordered products are unavailable. In such situations, we try to deliver the orders in parts. In such situations, you will be duly informed by our customer service executive.</p>
</div>
</div>
</div>
</div>
<script>
jQuery(document).ready(function(){
jQuery('ul.tabs li').click(function(){
var tab_id = jQuery(this).attr('data-tab');
jQuery('ul.tabs li').removeClass('current');
jQuery('.tab-content').removeClass('current');
jQuery(this).addClass('current');
jQuery("#"+tab_id).addClass('current');
});
});
</script>
it's so simple, you can handle it yourself with pushstate (to update your URL) or you can use this library which made it piece of a cake already :)
Related
I´m making a site for myself and I´ve been stuck with this issue. The site has several categories, for example geometry -> triangles. When I'm scrolling through articles and do not have a filtered category on yet, everything is ok. But when I filter categories and choose a specific one, for example triangles, all other articles that do not concern triangles get hidden. But that's not the issue. The problem is, if the articles for triangles where on the page 3 while the filter was off and you could see all the articles all together, then even after the filter is on the chosen category will be left on the page 3 and won't move to the first page. How do I fix this?
bodyOfmainPage.php
<main class="index-main">
<section class="articles">
<div class="article_content container container--pall">
<h1 class="heading">მთავარი გვერდი</h1>
<div class="article_grid">
<?php $idM=get_size(); ?>// number of articles
<?php for($id=$idM;$id>0;$id--): ?>
<?php $idN= get_num_size($id);?>
<div class="article_item" href="#" data-id ="<?= intval(($idM - $id)/4 + 1) ?>" data-category="<?= get_data_category($id) ?>">
<div class="article_image" style="background-image: url('<?= get_img_url($id) ?>')"> </div>
<div class="article-text">
<div class="article_date"><?= get_article_date($id) ?></div>
<div class="article_title"><?= get_article_title($id) ?></div>
<div class="article_description"><?= get_article_description($id) ?></div>
<div class="hashtag"><?= get_hashtag($id) ?></div>
<div class="butt">
<a class="AB" href="<?= get_article_link($id) ?>">
<button type="button" class="clickA" >გადასვლა</button></a>
</div>
</div>
</div>
<?php endfor; ?>
</div>
</div>
</section>
<div class="num">
<ul class="contentNum">
<li class="navigation" data-id ="1">1</li>
<li class="navigation" data-id ="2">2</li>
<li class="navigation" data-id ="3">3</li>
<li class="navigation" data-id ="4">4</li>
<li class="navigation" data-id ="5">5</li>
</ul>
</div>
</main>
I have been working on a job-listing website during the last few weeks as a self taught CS student. I finished the front end of the website in July and now I am learning mySQL and PHP to produce the back-end.
So, on the current "job listing" page search.html, there is currently 4 listing in the page but I typed those directly on the html when I was making the front-end just to see how it will look like.
I have build my database like this and added few examples:
I also made a back-end page to let the user add a a new listing and it is working.
I am not sure it was a good idea to start with the front-end. I am now trying to display three columns (title, location, type) of eachrowbased on my specific front-end layout. I won't display thedate` yet since I have not created it on mySQL.
search.html
<div class="job-listing">
<div class="container">
<div class="job-number">
<h2>We Found <span id="number-jobs-total" class="text-secondary"></span> Offers For <span>You</span> </h2>
</div>
<ul class="job-board">
<li class="job job-1">
<div class="job-title">
<h2>Process Engineer</h2>
</div>
<div class="job-location">
<p>Location: Naypyitaw</p>
</div>
<div class="job-type">
<p>Type: Full-Time</p>
</div>
<div class="job-date">
<p>Published on 07/19/2019</p>
</div>
<div class="job-industry">
<p>Engineering</p>
</div>
<ul class="job-keywords">
<li>Engineering</li>
<li>Science</li>
</ul>
</li>
<li class="job job-2">
<div class="job-title">
<h2>Chief Financial Officier</h2>
</div>
<div class="job-location">
<p>Location: Naypyitaw</p>
</div>
<div class="job-type">
<p>Type: Full-Time</p>
</div>
<div class="job-date">
<p>Published on 07/18/2019</p>
</div>
</li>
<li class="job job-3">
<div class="job-title">
<h2>Assistant CEO</h2>
</div>
<div class="job-location">
<p>Location: Naypyitaw</p>
</div>
<div class="job-type">
<p>Type: Part-Time</p>
</div>
<div class="job-date">
<p>Published on 07/18/2019</p>
</div>
</li>
<li class="job job-4">
<div class="job-title">
<h2>Front-End Developer</h2>
</div>
<div class="job-location">
<p>Location: Naypyitaw</p>
</div>
<div class="job-type">
<p>Type: Part-Time</p>
</div>
<div class="job-date">
<p>Published on 07/18/2019</p>
</div>
</li>
</ul>
<nav class="pagination-container">
<ul class="pagination">
<li>Previous</li>
<li>Next</li>
</ul>
</nav>
</div>
</div>
Things I will do later:
I need to protect my PHP code against injections
The pagination button is not working
I own a YouTube Network. For those of you who don't know what that is it's a alternative to YouTube's Ad Sense service effectively. Anyway, we have a control panel that we didn't make that tells us the total combined subscribers of all of the channels on the network. I thought that would look quite nice on our website as it may encourage people to choose my network over others. This is what the control panel looks like - https://i.imgur.com/ZfuH4BJ.png I asked a question on there comuntiy and there answer was along the lines of "It's pointless us making our API as everything we do is from YouTube's Data API. So I googled YouTube's Data API and yeah I managed to get it to work but only with 1 channel. The only way I can think of making a count on my website like the one on the control panel is by manually adding the channels into like a sum of adding the queried channel subscribers together. Also when new channels join the network it could be up to 100's per day so I wondered if there is a way to query the control panel to see when new people join the network and then send it back to my web server and add it into the code automaticly?? Below id the code of my page on my website that I display the data `
<!-- Gather YouTube Subscriber Count (PHP) -->
<?
// Calling api.
$subscribers = file_get_contents('https://www.googleapis.com/youtube/v3/channels? part=statistics&id=channel_key&key=api_key);
// Decoding json response
$response = json_decode($subscribers, true );
?>
<!-- Navigation -->
<nav class="navbar navbar-default navbar-fixed-top">
<div class="container">
<!-- Brand and toggle get grouped for better mobile display -->
<div class="navbar-header page-scroll">
<button type="button" class="navbar-toggle" data- toggle="collapse" data-target="#bs-example-navbar-collapse-1">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand page-scroll" href="#page-top">RiteSide Network</a>
</div>
<!-- Collect the nav links, forms, and other content for toggling -->
<div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
<ul class="nav navbar-nav navbar-right">
<li class="hidden">
</li>
<li>
<a class="page-scroll" href="../index.html"><i class="fa fa-arrow-left"></i> Return</a>
</li>
</ul>
</div>
<!-- /.navbar-collapse -->
</div>
<!-- /.container-fluid -->
</nav>
<header>
<div class="container">
<div class="intro-text">
<div class="jumbotron" align="center" style="color:black;">
<h1>Partners</h1>
<br />
<p>Please Come back soon. This page is almost finished!</p><br /><br />
<h1>Subscribers: <? // echoing subscribers count.
echo $count = intval($response['items'][0]['statistics']['subscriberCount']);?></h1>
</div>
</div>
</div>
</header>
<p> </p>
</body>`
Any Help is greatly appreciated! If you need any more details explaining, just say.
Thanks! Charlie :)
I seem to be having an issue with the pagination on the news section appending an /index/ when using the {pagination_links} tag.
My news page has a template path of news/index and the posts template is news/post.
I am using structure with the news/post as a listing attached to the news/index page, to add|edit posts.
If you have a look at the website in question: http://www.wilbyltd.co.uk/news scroll to the bottom you will see the pagination, if you click either 1|2|3 or next page or last page you will get the page requested, the url looks like /news/P6, however now on this next page if you go to the pagination again and click any of them you will notice it has gone back to page 1 and the url has /news/index it seems to be appending or inserting between links /index/.
I have tried to the paginate_base="" in the channel entry but adding a base stops the categories from having a working pagination, categories also add /index/ between the links?
I have thought of hacking the core but seems the wrong approach just in case it ever gets updated.
I have tried .htaccess to remove the index, which didn't work.
RewriteRule ^/news/index/(.+)$ /news/$1 [L]
I have looked at the config for index.php which has been taken off and .htaccess has been used.
I have looked at the channel settings.
I have tried dynamic="off"|dynamic="on"
I understand that news/index it the correct path for the page to view, but if this is the case why doesn't it pick up the pagination?
If anyone could shed some light in to this I would be really grateful, here is the code containing the pagination.
{exp:channel:entries channel="posts" limit="6" dynamic="on" paginate="bottom" orderby="entry_date" sort="desc"}
<div class="news-snippet span9">
<a href="{url_title_path=">
<div class="date-published textalign-center">
<span class="day">{entry_date format="%d"}</span><span class="day-suffix">{entry_date format="%S"}</span>
<span class="month">{entry_date format="%F"}</span>
</div>
</a>
<div class="news-snippet-body pull-right">
<div class="news-snippet-top-shadow">
<div class="news-snippet-bottom-shadow">
<a href="{url_title_path=">
<div class="news-snippet-content clearfix">
<div class="title">
<h3>{title}</h3>
</div>
{if news_feature_image}
<div class="clearfix image">
<img src="{news_feature_image}" />
</div>
{/if}
<p>{news_short_description}</p>
</div><!-- end content -->
</a>
<div class="news-snippet-options clearfix">
<div class="news-tags pull-left">
<i class="icon-tags"></i>
{exp:tagger:tags entry_id="{entry_id}" }
<span class="label label-inverse tags">{tagger:tag_name}</span>
{/exp:tagger:tags}
</div>
<div class="social-share pull-right textalign-center">
<i class="icon-random"></i>
<a class="addthis_button"url="{url_title_path="title="{title}" href="http://www.addthis.com/bookmark.php?v=300&pubid=ra-5141a60a37fa6e4e">Share</a>
</div>
</div>
</div><!-- end bottom-shadow -->
</div><!-- end top-shadow -->
</div><!-- end snippet-body -->
</div><!-- end news-snippet -->
{paginate}
<div class="clearfix paginate">
{pagination_links}
<div class="total-pages pull-left">
<p>Page {current_page} of {total_pages} pages</p>
</div>
<div class="pagination pagination-mini pull-right">
<ul>
{first_page}
<li>First Page</li>
{/first_page}
{previous_page}
<li>Previous Page</li>
{/previous_page}
{page}
<li>{pagination_page_number}</li>
{/page}
{next_page}
<li>Next Page</li>
{/next_page}
{last_page}
<li>Last Page</li>
{/last_page}
</ul>
</div>
{/pagination_links}
</div><!-- end clearfix -->
{/paginate}
{/exp:channel:entries}
I have also had this on Ellis Labs forum for a couple of weeks: http://ellislab.com/forums/viewthread/237601/
Try to override the {paginate_base} parameter in your channel entries tag
{exp:channel:entries channel="posts" paginate_base="news/" ...}
http://ellislab.com/expressionengine/user-guide/modules/channel/channel_entries.html#paginate-base
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();
});