How to add multiple YouTube subscriber counts together - php

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 :)

Related

how to display jquery tab id in url and active same tab?

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 :)

how to change title with data in database laravel backpack

im new at laravel backpack.
Here i want to change the title in layout with my data in database
this is the image
i want change that 'Backpack' with name in database like:
$user = DB::table('users')->where('users_id','=', '1')->get('users_name');
can i know how to change it with
the 'users_name' from database? Until know i dont know how to change it.
Thanks before
It's in the project_name/resources/views/vendor/backpack/base/layout.blad.php
<header class="main-header">
<!-- Logo -->
<a href="{{ url('') }}" class="logo"> <!-- Here's what r u looking for -->
<!-- mini logo for sidebar mini 50x50 pixels -->
<span class="logo-mini">{!! config('backpack.base.logo_mini') !!}</span>
<!-- logo for regular state and mobile devices -->
<span class="logo-lg">{!! config('backpack.base.logo_lg') !!}</span>
</a>
<!-- Header Navbar: style can be found in header.less -->
<nav class="navbar navbar-static-top" role="navigation">
<!-- Sidebar toggle button-->
<a href="#" class="sidebar-toggle" data-toggle="offcanvas" role="button">
<span class="sr-only">{{ trans('backpack::base.toggle_navigation') }}</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</a>
#include('backpack::inc.menu')
</nav>
</header>
1st Way (recommended)
{!! config('backpack.base.logo_mini') !!} to
{{ DB::table('users')->where('users_id','=', '1')->get('users_name') }}
Or whatever.
2nd Way
In the project_name/config/backpack/base.php
// Menu logos
'logo_lg' => '<b>Back</b>pack',
'logo_mini' => '<b>B</b>p',
Edit '<b>Back</b>pack' for your custom large size logo and edit '<b>B</b>p' for your custom mini size logo .
UPDATE
If you want to show the authenticated user name,
{{ Auth::user()->user_name }}

Assign SQL rows unique pages

sorry if this is a bit vague although I really don't know how to explain this one.
Basically I already have a listing page that lists all of the rows in my database into a html template that lists each row into an eCommerce style category page using PHP.
I am using this code for the listing page using PDO:
<?php while($row = $results->fetch(PDO::FETCH_ASSOC))
{
echo '
<div class="listing-container">
<h3 class="model-listing-title clearfix">'.$row["Make"].' '.$row["Model"].' '.$row["Variant"].'</h3>
<h3 class="price-listing">£'.number_format($row['Price']).'</h3>
</div>
<div class="listing-container-spec">
<img src="'.(explode(',', $row["PictureRefs"])[0]).'" class="stock-img-finder"/>
<div class="ul-listing-container">
<ul class="overwrite-btstrp-ul">
<li class="diesel-svg list-svg">'.$row["FuelType"].'</li>
<li class="saloon-svg list-svg">'.$row["Bodytype"].'</li>
<li class="gear-svg list-svg">'.$row["Transmission"].'</li>
<li class="color-svg list-svg">'.$row["Colour"].'</li>
</ul>
</div>
<ul class="overwrite-btstrp-ul other-specs-ul h4-style">
<li>Mileage: '.number_format($row["Mileage"]).'</li>
<li>Engine size: '.$row["EngineSize"].'cc</li>
</ul>
<button href="#" class="btn h4-style checked-btn hover-listing-btn"><span class="glyphicon glyphicon-ok"></span> History checked
</button>
<button href="#" class="btn h4-style more-details-btn hover-listing-btn tst-mre-btn"><span class="glyphicon glyphicon-list"></span> More details
</button>
<button href="#" class="btn h4-style test-drive-btn hover-listing-btn tst-mre-btn"><span class="test-drive-glyph"></span> Test drive
</button>
<h4 class="h4-style listing-photos-count"><span class="glyphicon glyphicon-camera"></span> 5 More photos</h4>
</div>
';
} ?>
</div>
Now what I want to do is create a page for each of the SQL rows however I am unsure how I can do this, just like an eBay product page really.
My main question is what method could I do to create individual pages that are dedicated to each SQL row?
If anyone could shed a bit of light on this for me it would be much appreciated.
Knowing you can extract data from a page to another using $_POST['name-of-your-element'], I would say to do something like this :
Creating a php page dedicated to display information of one specific row
Putting some $_POST['...'] call to display the exact data
To do this, instead of just displaying your row in your actual page, you should create form for each row, and then adding a submit button for each row which will launch the "display row page" with the correct information. I would see something like this for each row :
<form method = "post" action = "displayData_Make.php">
<div id = "Make" name = "Make">
Make : <?php echo $row['Make'] ?>
</div>
<input type = "submit" value = "more information..." />
</form>
Then in you "displayData_Make.php" receive your information and display them like you want :
<?php
$info = $_POST['Make'];
// Do what you want with this data
// Display, etc...
?>
<!--
Some html code
-->

Bootstrap add active class to nav bar when nav is a PHP include

I'm currently building a site with bootstrap and would like to know if it's possible to, and how to add the class="active" attribute to a link on the nav menu. I saw another post similar to this on this very site, however it didn't work on the page using the Bootstrap carousel. I removed all links to jQuery and other javascript on the page but it still wasn't working.
On each page the nav is called with a php include, as is the code for the link state. So picture the markup like so:
<head>
<?php include_once('head.php'); ?>
</head>
<body>
<?php include_once('nav.php'); ?>
</body>
in the head.php is the following code, which I got from another post on this site:
<script>
/*menu handler*/
$(function(){
function stripTrailingSlash(str) {
if(str.substr(-1) == '/') {
return str.substr(0, str.length - 1);
}
return str;
}
var url = window.location.pathname;
var activePage = stripTrailingSlash(url);
$('.nav li a').each(function(){
var currentPage = stripTrailingSlash($(this).attr('href'));
if (activePage == currentPage) {
$(this).parent().addClass('active');
}
});
});
</script>
and in the nav.php I've got:
<nav class="navbar navbar-fixed-top navbar-default" role="navigation">
<div class="container">
<div class="navbar-header">
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-ex1-collapse">
<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" href="index.php"><img src="assets/img/logo.png" /></a>
</div>
<!-- Collect the nav links, forms, and other content for toggling -->
<div class="collapse navbar-collapse navbar-ex1-collapse">
<ul class="nav navbar-nav">
<li>About</li>
<li>Services</li>
<li>Home </li>
</ul>
</div>
<!-- /.navbar-collapse -->
</div>
<!-- /.container -->
</nav>
Each page is named as per the href attr.
This works on a duplicate of template.php, however it doesn't work on index.php, which is making me think it's something to do with the carousel...
I've also tried using the data-toggle="pill" as recommended somewhere but that doesn't work.
Any assistance will be appreciated. I'ts on a local vps at the moment, however I can assign it a public IP.
Thanks in advance!
Ash
Because the script is being included in the head.php before the navbar has been loaded, it has nothing to apply the 'active' class to. Perhaps place the JavaScript in a separate include after the navbar.
If that doesn't work, I used this script to apply the active class to a specific menu item, just place it after the navbar include and change the href to the desired 'active' button
<script>
$(document).ready(function(){
$('a[href^="home.html"]').addClass('active');
});
</script>

Strange Pagination issues adding /index/ between links - Expression Engine

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

Categories