Skip to content

Loading…

Example theme changes #1

Merged
merged 5 commits into from

2 participants

@afrerich

I tried out mtv on my install. I found one bug - the meaning of newer/older was reversed in pagination for both the simple theme and the twentyeleven theme.

I also had to make several modifications to the twentyeleven theme to even get it to run. I added several functions to the templatetags file to accomplish this.

In addition, I added category and tag pages to the twentyeleven theme.

@rnagle rnagle merged commit aba5efc into newsapps:master
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
View
8 mtv-twentyeleven/templates/_pagination.html
@@ -2,14 +2,14 @@
<h3 class="assistive-text">{{ __( 'Post navigation', 'twentyeleven' ) }}</h3>
<div class="nav-previous">
{% if page_num > 1 %}
- <a href="page/{{ page_num - 1 }}/" {{ apply_filters( 'next_posts_link_attributes', '' ) }}>
- {{ __( '<span class="meta-nav">&larr;</span> Older posts', 'twentyeleven' ) }}</a>
+ <a href="/page/{{ page_num - 1 }}/" {{ apply_filters( 'next_posts_link_attributes', '' ) }}>
+ {{ __( '<span class="meta-nav">&larr;</span> Newer posts', 'twentyeleven' )|raw }}</a>
{% endif %}
</div>
<div class="nav-next">
{% if more_posts %}
- <a href="page/{{ page_num + 1 }}/" {{ apply_filters( 'previous_posts_link_attributes', '' ) }}>
- {{ __( 'Newer posts <span class="meta-nav">&rarr;</span>', 'twentyeleven' ) }}</a>
+ <a href="/page/{{ page_num + 1 }}/" {{ apply_filters( 'previous_posts_link_attributes', '' ) }}>
+ {{ __( 'Older posts <span class="meta-nav">&rarr;</span>', 'twentyeleven' )|raw }}</a>
{% endif %}
</div>
</nav><!-- #nav-above -->
View
2 mtv-twentyeleven/templates/_sidebar.html
@@ -20,6 +20,8 @@ <h3 class="widget-title">{{ __( 'Meta', 'twentyeleven' ) }}</h3>
</ul>
</aside>
+ {% else %}
+ {{ dynamic_sidebar( 'sidebar-1' ) }}
{% endif %}
</div><!-- #secondary .widget-area -->
{% endif %}
View
8 mtv-twentyeleven/templates/base.html
@@ -15,8 +15,8 @@
<meta charset="{{ get_bloginfo( 'charset' ) }}" />
<meta name="viewport" content="width=device-width" />
<title>{% block title %}
- {{ wp_title('|', true, 'right') }}{{ get_bloginfo('name') }}{% if get_bloginfo( 'description', 'display' ) and is_home() %}
- | {{ get_bloginfo( 'description', 'display' ) }}{% endif %}
+ {{ wp_title('|', true, 'right') }}{{ get_bloginfo('name')|raw }}{% if get_bloginfo( 'description' ) and is_home() %}
+ | {{ get_bloginfo( 'description' )|raw }}{% endif %}
{% endblock %}</title>
<link rel="profile" href="http://gmpg.org/xfn/11" />
<link rel="stylesheet" type="text/css" media="all" href="{{ get_bloginfo( 'stylesheet_url' ) }}" />
@@ -36,8 +36,8 @@
<div id="page" class="hfeed">
<header id="branding" role="banner">
<hgroup>
- <h1 id="site-title"><span><a href="{{ get_home_url( '/' ) }}" title="{{ esc_attr( get_bloginfo( 'name', 'display' ) ) }}" rel="home">{{ get_bloginfo( 'name' ) }}</a></span></h1>
- <h2 id="site-description">{{ get_bloginfo( 'description' ) }}</h2>
+ <h1 id="site-title"><span><a href="{{ get_home_url( '/' ) }}" title="{{ esc_attr( get_bloginfo( 'name', 'display' ) ) }}" rel="home">{{ get_bloginfo( 'name' )|raw }}</a></span></h1>
+ <h2 id="site-description">{{ get_bloginfo( 'description' )|raw }}</h2>
</hgroup>
{# TODO: create a template tag to do tricky header image stuff #}
View
2 mtv-twentyeleven/templates/single.html
@@ -17,6 +17,4 @@ <h3 class="assistive-text">Post navigation</h3>
</div><!-- #content -->
</div><!-- #primary -->
-{% include '_sidebar.html' %}
-
{% endblock %}
View
12 mtv-twentyeleven/templatetags/functions.php
@@ -2,3 +2,15 @@
$twig->addFunction('twentyeleven_get_theme_options', new Twig_Function_Function('twentyeleven_get_theme_options'));
$twig->addFunction('twentyeleven_footer_sidebar_class', new Twig_Function_Function('twentyeleven_footer_sidebar_class'));
+$twig->addFunction('twentyeleven_posted_on', new Twig_Function_Function('twentyeleven_posted_on'));
+
+
+$twig->addFunction('get_header_image', new Twig_Function_Function('get_header_image'));
+$twig->addFunction('get_header_textcolor', new Twig_Function_Function('get_header_textcolor'));
+$twig->addFunction('wp_title', new Twig_Function_Function('wp_title'));
+$twig->addFunction('wp_get_archives', new Twig_Function_Function('wp_get_archives'));
+$twig->addFunction('wp_register', new Twig_Function_Function('wp_register'));
+$twig->addFunction('wp_loginout', new Twig_Function_Function('wp_loginout'));
+$twig->addFunction('wp_meta', new Twig_Function_Function('wp_meta'));
+
+
View
4 mtv-twentyeleven/urls.php
@@ -9,6 +9,10 @@
'twentyeleven\views\home',
'/^search\/?$/' =>
'twentyeleven\views\search',
+ '/^tags\/?(?P<tag>[^\/]+)$/' =>
+ 'twentyeleven\views\search',
+ '/^category\/?(?P<category>[^\/]+)$/' =>
+ 'twentyeleven\views\search',
'/(?:[0-9]{4}\/)(?:[0-9]{2}\/){1}(?P<name>[^\/]+)\/?$/' => # year/month/slug
'twentyeleven\views\single',
View
29 mtv-twentyeleven/views.php
@@ -69,7 +69,34 @@ function page( $request ) {
}
-function search( $request ) {}
+function search( $request ) {
+ shortcuts\set_query_flags('search');
+
+ $page_num = ($request['page_num'])? $request['page_num']: 1;
+ $category = ($request['category'])? $request['category']: null;
+ $tag = ($request['tag'])? $request['tag']: null;
+
+ $args = array('post_type' => 'post',
+ 'posts_per_page' => 10,
+ 'order' => 'DESC',
+ 'paged' => $page_num);
+
+ if ($category) { $args['category_name'] = $category; }
+ if ($tag) { $args['tag'] = $tag; }
+
+ $posts = PostCollection::filter($args);
+
+ $max_pages = $posts->wp_query->max_num_pages;
+ $more_posts = ($max_pages > 1 && $max_pages != $page_num)? true:false;
+
+ $template_array = array(
+ 'page_num' => $page_num,
+ 'more_posts' => $more_posts,
+ 'posts' => $posts->models
+ );
+
+ shortcuts\display_template('index.html', $template_array);
+}
function feed( $request ) {}
View
4 simple-mtv/templates/_pagination.html
@@ -3,13 +3,13 @@
<h3 class="assistive-text">Post navigation</h3>
<div class="nav-previous">
{% if page_num > 1 %}
- <a href="{{ location }}/page/{{ page_num - 1 }}/"><span class="meta-nav">&larr;</span> Older posts</a>
+ <a href="{{ location }}/page/{{ page_num - 1 }}/"><span class="meta-nav">&larr;</span> Newer posts</a>
{% endif %}
</div>
<div class="nav-next">
{% if more_posts %}
<a href="{{ location }}/page/{{ page_num + 1 }}/">
- Newer posts <span class="meta-nav">&rarr;</span></a>
+ Older posts <span class="meta-nav">&rarr;</span></a>
{% endif %}
</div>
</nav>
View
8 simple-mtv/templates/base.html
@@ -16,8 +16,8 @@
<meta charset="{{ get_bloginfo( 'charset' ) }}" />
<meta name="viewport" content="width=device-width" />
<title>{% block title %}
- {{ get_bloginfo('name') }}{% if get_bloginfo( 'description', 'display' ) and is_home() %}
- | {{ get_bloginfo( 'description', 'display' ) }}{% endif %}
+ {{ get_bloginfo('name')|raw }}{% if get_bloginfo( 'description' ) and is_home() %}
+ | {{ get_bloginfo( 'description' )|raw }}{% endif %}
{% endblock %}</title>
<link rel="profile" href="http://gmpg.org/xfn/11" />
<link rel="stylesheet" type="text/css" media="all" href="{{ get_bloginfo( 'stylesheet_url' ) }}" />
@@ -33,8 +33,8 @@
<div id="page" class="hfeed">
<header id="branding" role="banner">
<hgroup>
- <h1 id="site-title"><span><a href="{{ get_home_url( '/' ) }}" title="{{ esc_attr( get_bloginfo( 'name', 'display' ) ) }}" rel="home">{{ get_bloginfo( 'name' ) }}</a></span></h1>
- <h2 id="site-description">{{ get_bloginfo( 'description' ) }}</h2>
+ <h1 id="site-title"><span><a href="{{ get_home_url( '/' ) }}" title="{{ esc_attr( get_bloginfo( 'name' ) ) }}" rel="home">{{ get_bloginfo( 'name' )|raw }}</a></span></h1>
+ <h2 id="site-description">{{ get_bloginfo( 'description' )|raw }}</h2>
</hgroup>
{# search functionality not implemented yet -- why don't you give us a hand with it? #}
{# {% include '_searchform.html' %} #}
Something went wrong with that request. Please try again.