Last active
April 20, 2017 08:26
-
-
Save CNG/248003ad7877db9197bf to your computer and use it in GitHub Desktop.
Author page views Movable Type template
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<mt:Ignore>this is password protected by the accompanying .htaccess and .htpw files</mt:Ignore> | |
<mt:Section regex_replace="/\n\s*\n/mg","\n"> | |
<$mt:Include module="timing" part="start"$> | |
<mt:Ignore>Number of years to show</mt:Ignore> | |
<$mt:Var name="total_years" value="2"> | |
<mt:Ignore>Store values for past $total_years years to test entry dates against. Will result in something like: Y0=2013; Y1=2012; Y2=2011</mt:Ignore> | |
<$mt:Date format="%Y" setvar="now_year"$> | |
<mt:For from="1" to="$total_years"> | |
<mt:SetVarBlock name="var_name">Y<$mt:Var name="__index__"$></mt:SetVarBlock> | |
<$mt:Var name="__index__" op="--" setvar="years_to_subtract"$> | |
<$mt:Var name="now_year" op="-" value="$years_to_subtract" setvar="$var_name"$> | |
</mt:For> | |
<mt:SetVars> | |
M01=01 | |
M02=02 | |
M03=03 | |
M04=04 | |
M05=05 | |
M06=06 | |
M07=07 | |
M08=08 | |
M09=09 | |
M10=10 | |
M11=11 | |
M12=12 | |
</mt:SetVars> | |
<mt:Ignore>Information to show for each entry</mt:Ignore> | |
<mt:SetVarTemplate name="entry_info"><$mt:EntryDate format="%Y-%m-%d"$>: <$mt:BlogName$>: <$mt:EntryTitle$></mt:SetVarTemplate> | |
<?php | |
require 'author_pageviews.php'; | |
?><!DOCTYPE html> | |
<html> | |
<head> | |
<title>Author story counts by year</title> | |
<style> | |
table { border-collapse: collapse; } | |
td { border: 1px solid #777; text-align: right; padding: 3px; font-family: sans-serif; } | |
td:first-child { text-align: left; } | |
thead tr td { text-align: center; } | |
.details { display: none; } | |
.value{ cursor: pointer; } | |
a { text-decoration: none; color: blue; } | |
</style> | |
<script type="text/javascript" src="//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script> | |
<script> | |
$(document).ready(function() { | |
$('.value').click(function(){ | |
alert($(this).siblings('.details').text()); | |
}); | |
}); | |
</script> | |
</head> | |
<body> | |
<table> | |
<thead> | |
<tr> | |
<td rowspan="3">Author</td> | |
<td colspan="<$mt:Var name="total_years" op="*" value="13"$>">Entries</td> | |
<td colspan="3">Total</td> | |
</tr> | |
<tr> | |
<mt:For from="1" to="$total_years"> | |
<$mt:Var name="total_years" op="-" value="$__index__" setvar="years_to_subtract"$> | |
<td colspan="13"><$mt:Var name="now_year" op="-" value="$years_to_subtract"$></td> | |
</mt:For> | |
<td>Entries</td> | |
<td colspan="2">Pageviews</td> | |
</tr> | |
<tr> | |
<mt:For from="1" to="$total_years"> | |
<mt:For from="1" to="12"> | |
<mt:SetVarBlock name="var_name">M<$mt:Var name="__index__" sprintf="%02d"$></mt:SetVarBlock> | |
<td><$mt:Var name="$var_name"$></td> | |
</mt:For> | |
<td>Year</td> | |
</mt:For> | |
<td>All</td> | |
<td>YTD</td> | |
<td>30 days</td> | |
</tr> | |
</thead> | |
<mt:Entries sort_by="title" sort_order="ascend" limit="999999"> | |
<mt:Ignore>Reset hash variables and total counter</mt:Ignore> | |
<mt:For from="1" to="$total_years"> | |
<mt:SetVarBlock name="var_name">entriesY<$mt:Var name="__index__"$></mt:SetVarBlock> | |
<$mt:Var name="$var_name" value=""$> | |
<mt:For from="1" to="12"> | |
<mt:SetVarBlock name="var_name_month"><$mt:Var name="var_name"$>M<$mt:Var name="__index__" sprintf="%02d"$></mt:SetVarBlock> | |
<$mt:Var name="$var_name_month" value=""$> | |
</mt:For> | |
</mt:For> | |
<$mt:Var name="total_entries" value="0"$> | |
<$mt:Var name="total_entries_displayed" value="0"$> | |
<mt:Ignore> | |
Create variables to store entry info for current author like: | |
entriesY1{entry_id} = entry_info vartemplate results (consider removing this) | |
entriesY1M01{entry_id} = entry_info vartemplate results | |
</mt:Ignore> | |
<mt:EntryLinkingEntries field="authors_byline_entry"> | |
<mt:For from="1" to="$total_years"> | |
<mt:SetVarBlock name="var_name">Y<$mt:Var name="__index__"$></mt:SetVarBlock> | |
<mt:SetVarBlock name="var_name_entries">entriesY<$mt:Var name="__index__"$></mt:SetVarBlock> | |
<$mt:Var name="__index__" op="--" setvar="years_to_subtract"$> | |
<$mt:Var name="now_year" op="-" value="$years_to_subtract" setvar="$var_name"$> | |
<$mt:Var name="$var_name" setvar="curr_year"$> | |
<mt:If tag="EntryDate" format="%Y" eq="$curr_year"> | |
<mt:SetVarBlock name="hash_address"><$mt:Var name="var_name_entries"$>{<$mt:EntryID$>}</mt:SetVarBlock> | |
<mt:SetVarBlock name="$hash_address"><$mt:Var name="entry_info"$></mt:SetVarBlock> | |
<mt:SetVarBlock name="hash_address"><$mt:Var name="var_name_entries"$>M<$mt:EntryDate format="%m"$>{<$mt:EntryID$>}</mt:SetVarBlock> | |
<mt:SetVarBlock name="$hash_address"><$mt:Var name="entry_info"$></mt:SetVarBlock> | |
<$mt:Var name="total_entries_displayed" op="++" setvar="total_entries_displayed"$> | |
</mt:If> | |
</mt:For> | |
<$mt:Var name="total_entries" op="++" setvar="total_entries"$> | |
</mt:EntryLinkingEntries> | |
<mt:If name="total_entries_displayed" gt="0"> | |
<tr> | |
<td><a href="<$mt:EntryPermalink$>"><$mt:EntryTitle$></a></td> | |
<mt:For from="1" to="$total_years"> | |
<$mt:Var name="__index__" op="--" setvar="index"$> | |
<$mt:Var name="total_years" op="-" value="$index" setvar="year"$> | |
<mt:SetVarBlock name="var_name_entries">entriesY<$mt:Var name="year"$></mt:SetVarBlock> | |
<mt:For from="1" to="12"> | |
<mt:SetVarBlock name="var_name_entries_month"><$mt:Var name="var_name_entries"$>M<$mt:Var name="__index__" sprintf="%02d"$></mt:SetVarBlock> | |
<td> | |
<mt:If tag="Var" name="$var_name_entries_month" function="count" gt="0"> | |
<a class="value"><$mt:Var name="$var_name_entries_month" function="count"$></a> | |
<mt:SetVarBlock name="details"> | |
<$mt:EntryTitle$>’s <$mt:Var name="now_year" op="-" value="$year" setvar="temp"$><$mt:Var name="temp" op="++"$> entries | |
| |
<mt:Loop name="$var_name_entries_month"> | |
<mt:Ignore><$mt:Var name="__key__"$>: </mt:Ignore><$mt:Var name="__value__"$> | |
</mt:Loop> | |
</mt:SetVarBlock> | |
<p class="details"><$mt:Var name="details" regex_replace="/^\s*(.*?)\s*$/mg","$1"$></p> | |
</mt:If> | |
</td> | |
</mt:For> | |
<td> | |
<mt:If tag="Var" name="$var_name_entries" function="count" gt="0"> | |
<a class="value"><$mt:Var name="$var_name_entries" function="count"$></a> | |
<mt:SetVarBlock name="details"> | |
<$mt:EntryTitle$>’s <$mt:Var name="now_year" op="-" value="$year" setvar="temp"$><$mt:Var name="temp" op="++"$> entries | |
| |
<mt:Loop name="$var_name_entries"> | |
<mt:Ignore><$mt:Var name="__key__"$>: </mt:Ignore><$mt:Var name="__value__"$> | |
</mt:Loop> | |
</mt:SetVarBlock> | |
<p class="details"><$mt:Var name="details" regex_replace="/^\s*(.*?)\s*$/mg","$1"$></p> | |
</mt:If> | |
</td> | |
</mt:For> | |
<td><$mt:Var name="total_entries"$></td> | |
<td><?php echo array_key_exists('<$mt:EntryTitle encode_php="q"$>', $pageviewsYTD) ? $pageviewsYTD['<$mt:EntryTitle encode_php="q"$>']: 0; ?></td> | |
<td><?php echo array_key_exists('<$mt:EntryTitle encode_php="q"$>', $pageviews30D) ? $pageviews30D['<$mt:EntryTitle encode_php="q"$>']: 0; ?></td> | |
</tr> | |
</mt:If> | |
</mt:Entries> | |
</table> | |
<$mt:Include module="timing" part="stop"$> | |
</body> | |
</html> | |
</mt:Section> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment