<?xml version="1.0" encoding="utf-8" standalone="yes" ?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
  <channel>
    <title>Php on Notes</title>
    <link>https://www.simplicidade.org/tags/php/index.xml</link>
    <description>Recent content in Php on Notes</description>
    <generator>Hugo -- gohugo.io</generator>
    <language>en-us</language>
    <managingEditor>melo@simplicidade.org (Pedro Melo)</managingEditor>
    <webMaster>melo@simplicidade.org (Pedro Melo)</webMaster>
    <copyright>(c) 2016 Pedro Melo.</copyright>
    <atom:link href="/tags/php/index.xml" rel="self" type="application/rss+xml" />
    <atom:link rel="hub" href="https://pubsuhhubbub.superfeedr.com/"/>
    
    <item>
      <title>Upgraded individual article archive templates</title>
      <link>https://www.simplicidade.org/notes/2005/10/12/upgraded-individual-article-archive-templates/</link>
      <pubDate>Wed, 12 Oct 2005 08:00:17 +0000</pubDate>
      <author>melo@simplicidade.org (Pedro Melo)</author>
      <guid>https://www.simplicidade.org/notes/2005/10/12/upgraded-individual-article-archive-templates/</guid>
      <description>&lt;p&gt;I like to have the same sidebar on the right of my pages, both in the main page and in the individual article pages.&lt;/p&gt;

&lt;p&gt;With MT, I always edited the templates to add the same sidebar on both the main index template and in the individual archive template.&lt;/p&gt;

&lt;p&gt;Today, I tried something new. I added a new index template, sidebar.html, and copied the sidebar from the main index template. Then I removed that content from the main index template and replaced it with a include of the new template. Also I edited the individual article template in the archive section and added the same include there. You also have to change the class of the &lt;body&gt; element to &amp;ldquo;layout-two-column-right&amp;rdquo;.&lt;/p&gt;

&lt;p&gt;Now, my sidebar code is in a single template, for easy updating, and I can update a single template to change the sidebar on all the pages.&lt;/p&gt;

&lt;p&gt;The include part is done in realtime using PHP. You can, of course, use whatever you want, but for simple include stuff, PHP is the best solution.&lt;/p&gt;

&lt;p&gt;So, recap: to make certain elements of your blog layout easy to update (as in, having them in a single place), do this:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;create a new index template with the common elements;&lt;/li&gt;
&lt;li&gt;replace the places where they where being used with includes;&lt;/li&gt;
&lt;li&gt;adjust css classes if needed.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;For example, to make the main page sidebar appear on all the templates, do this:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;from the main index template, take out the &lt;code&gt;&amp;lt;div&amp;gt;&lt;/code&gt; with the &amp;ldquo;beta&amp;rdquo; class;&lt;/li&gt;
&lt;li&gt;replace it with a &lt;code&gt;&amp;lt;?php include &amp;quot;sidebar.html&amp;quot; ?&amp;gt;&lt;/code&gt;;&lt;/li&gt;
&lt;li&gt;create a new sidebar template, and paste the original code there (make sure you check the &amp;ldquo;Rebuild this template automatically when rebuilding index templates&amp;rdquo;);&lt;/li&gt;
&lt;li&gt;alter the individual article archive template, change the &lt;code&gt;&amp;lt;body&amp;gt;&lt;/code&gt; element to the class &amp;ldquo;layout-two-column-right&amp;rdquo; and after the &amp;ldquo;alfa&amp;rdquo; &lt;code&gt;&amp;lt;div&lt;/code&gt;, add something like &lt;code&gt;&amp;lt;? php include(&amp;quot;../../../sidebar.html&amp;quot;) ?&amp;gt;&lt;/code&gt;. You have to adjust your path to the correct number of directories you crawl back, it depends on your archive URL layout.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Then make sure you setup Apache to filter all the HTML files via PHP. And then rebuild your entire site.&lt;/p&gt;
</description>
    </item>
    
  </channel>
</rss>