16 - Implementing the Weblog, Global Variables, and Passing Variables in Variables

There are a number of ways to implement a weblog with ExpressionEngine.  Let me explain at a high level the approach I’m taking here and you can decide if it meets your needs or not.

 
Download the EE Code for 16 - Implementing the Weblog, Global Variables, and Passing Variables in Variables

Weblog Implementation Overview
Most weblogs will require a number of templates. However, depending on your requirements and expectations of traffic to a weblog, you can make some choices that will save you some time and trouble on the front end.

Weblogs being, well, weblogs, they usually have the following needs:

  • An index template that comes up by default, and shows the last x number of posts with the newest at the top.  If there are longer posts, often this template only shows part of the post and has a “read more” link of some sort, which leads to the…
  • Single-view template that shows an entire post
  • Comments template where users can respond
  • Permalink template which places this post at a specific URL that won’t change as new content gets added to the weblog
  • Category Index - if the weblog posts are categorized, this view shows the latest posts assigned to the desired category
  • Archive - most often this is broken down by month
  • RSS or Atom feed

That’s quite a list, no?

However - especially for weblogs like we’re building that are part of a business site (rather than really being the entire site), we can repurpose one template to serve multiple needs.  In this tutorial we’ll accomplish the weblog implementation with three main templates and a few new embedded templates.  The three main templates will be:

  • Weblog Index.  This will serve as the default index view, the category view and the archive view
  • Weblog Comments.  This will serve as the single-view, comments, and permalink template
  • RSS feed

If you expect your blog to be quite busy, or if it will have deep archives, or if you will want a different category view, you might consider dedicated templates for those purposes.  I prefer to start simple; so, for most clients just getting into blogs, I’ll start with this approach and modify it later based on actual need.

Onto the build!

Create Data Structures
To begin, you’ll first need to get the EE data structures in place.  You’ll need:

  • A new weblog.  In my case, and in all the sample templates I’ll be providing, this is called “weblog”.  Make sure commenting is enabled – the setting is found under Admin > Weblog Administration > Weblog Management > Edit Weblog Comment Posting Preferences > Allow Comments in This Weblog?
  • A Field Group.  I’m using the Default Field Group that installs with EE so will have fields of Summary, Body, and Extended Text.
  • A Category Group.  I created a weblog-specific Category Group called “weblog” with categories of Company News, Industry News, and Ramblings.  I entered short descriptions for each.
  • Remember to assign the new Category Group and Field Group to the new weblog.

Do Some Data Entry
Go ahead and make some entries in your new weblog, at least one per category.  Make sure to use all the fields so you’ll know if your templates function correctly.

Oh , and also post a new section heading type thing into your Miscellaneous Content Weblog.  Make sure it has a URL Title of “weblog.”

New Template Group
Create a new Template Group for the weblog-related templates.  In a fit of sheer creativity I’ve named mine “weblog”.

Weblog Main Templates - Index
Here is the code for the weblog/index template.  It has some higher-level EE coding in it, so will look a bit strange.

(Note – in order to have less word-wrapping I’ve removed some of the formatting of the code in these samples.  The text versions in the attached files will retain their formatting and might be easier to read).

{assign_variable:my_weblog="weblog"}
{assign_variable
:my_template_group="weblog"}
{assign_variable
:my_embedded_template_group="embeds"}
{assign_variable
:my_index_template=""}
{assign_variable
:my_comments_template="comments"}
{embed
="{my_embedded_template_group}/html_header" my_page_title="Weblog"}
<body>
<
div id="content">
{embed="{my_embedded_template_group}/logo_title"}
{embed
="{my_embedded_template_group}/main_nav" my_location="weblog"}
{embed
="{my_embedded_template_group}/search_section_intros" the_url_title="weblog"}

<div id="maincontent">
<
div id="right_side">

{embed="{my_embedded_template_group}/weblog_categories" the_index_template="{my_index_template}" the_template_group="{my_template_group}" the_weblog="{my_weblog}"}

{embed
="{my_embedded_template_group}/monthly_archives" the_index_template="{my_index_template}" the_template_group="{my_template_group}" the_weblog="{my_weblog}"}
{embed
="{my_embedded_template_group}/syndicate_block" the_template_group="{my_template_group}"}
</div><!-- close right_side -->
<
div id="left_side">
{exp:weblog:category_heading weblog="{my_weblog}"}
<h3>Category:&nbsp;{category_name}</h3>
{if category_description}
<p>{category_description}</p>
{/if}
<div class="horizontal_rule"></div>
{/exp:weblog:category_heading}
{exp
:weblog:entries weblog="{my_weblog}" orderby="date" sort="desc" limit="15" disable="trackbacks"}
<div class="entry">
<
h3><a href="{homepage}/{my_template_group}/{my_comments_template}/{url_title}">{title}</a></h3>
{summary}
{body}
{if extended}
<p><a href="{homepage}/{my_template_group}/{my_comments_template}/{url_title}">Read More...</a></p>{/if}
<div class="posted">
Posted by {author} on {entry_date format='%m/%d'} at {entry_date format='%h:%i %A'} in
{categories}
<a href="{path={my_template_group}/{my_index_template}}">{category_name}</a> &#8226;
{/categories}

{if allow_comments}
({comment_total}) <a href="{homepage}/{my_template_group}/{my_comments_template}/{url_title}#comments">Comments</a> &#8226;
{/if}
<a href="{homepage}/{my_template_group}/{my_comments_template}/{url_title}">Permalink</a>
</
div>
{paginate}
<div class="paginate">
<
span class="pagecount">Page {current_page} of {total_pages} pages</span>  {pagination_links}
</div>
{/paginate}
</div>
{/exp:weblog:entries}

</div><!-- close left side div -->
</
div><!-- close main content div -->
{embed="{my_embedded_template_group}/footer"}
</div>    <!-- close content div -->
</
body>
</
html

What’s up with all that assign_variable stuff?

Hang on – let’s get through all the new templates, then we’ll dig into it.  Don’t check out on me – this is pretty cool stuff.

Weblog Main Templates – Comments
Here’s the code for the new weblog/comments template:

{assign_variable:my_weblog="weblog"}
{assign_variable
:my_template_group="weblog"}
{assign_variable
:my_embedded_template_group="embeds"}
{assign_variable
:my_index_template="index"}
{assign_variable
:my_comments_template="comments"}

{embed
="{my_embedded_template_group}/html_header" my_page_title="Weblog | {exp:weblog:entries weblog="{my_weblog}" orderby="date" sort="desc" limit="1" disable="member_data|trackbacks|pagination|categories|custom_fields"}{title}{/exp:weblog:entries}"}

<body>
<
div id="content">
{embed="{my_embedded_template_group}/logo_title"}
{embed
="{my_embedded_template_group}/main_nav" my_location="weblog"}
{embed
="{my_embedded_template_group}/search_section_intros" the_url_title="weblog"}

<div id="maincontent">
<
div id="right_side">

{embed="{my_embedded_template_group}/weblog_categories" the_index_template="{my_index_template}" the_template_group="{my_template_group}" the_weblog="{my_weblog}"}
{embed
="{my_embedded_template_group}/monthly_archives" the_index_template="{my_index_template}" the_template_group="{my_template_group}" the_weblog="{my_weblog}"}
{embed
="{my_embedded_template_group}/syndicate_block" the_template_group="{my_template_group}"}

</div><!-- close right_side -->

<
div id="left_side">
{exp:weblog:entries weblog="{my_weblog}" orderby="date" sort="desc" limit="1" disable="member_data|trackbacks"}
<div class="entry">
<
h3>{title}</h3>
{summary}
{body}
{extended}
<div class="posted">
Posted by {author} on {entry_date format='%m/%d'} at {entry_date format='%h:%i %A'} in
{categories}
<a href="{path={my_template_group}/{my_index_template}}">{category_name}</a> &#8226;
{/categories}

{if allow_comments}
({comment_total}Comments
{
/if}

</div>
</
div>
{/exp:weblog:entries}

{embed
="{my_embedded_template_group}/weblog_entry_comments" the_weblog="{my_weblog}"}

</div><!-- close left side div -->

</
div><!-- close main content div -->
{embed="{my_embedded_template_group}/footer"}
</div>    <!-- close content div -->
</
body>
</
html

Weblog Main Templates – RSS
Make sure when you create the new template for the RSS feed, you choose RSS Page in the Template Type drop-down.  If you forget while creating the template, just click the Preferences link for the Template Group you put it in, and change it there.

Here’s the code:

Template Name: weblog/rss_2

{assign_variable:master_weblog_name="weblog"}
{exp
:rss:feed weblog="{master_weblog_name}"}
<?xml version
="1.0" encoding="{encoding}"?>
<rss version="2.0"
    
xmlns:dc=http://purl.org/dc/elements/1.1/
    
xmlns:sy=http://purl.org/rss/1.0/modules/syndication/
    
xmlns:admin=http://webns.net/mvcb/
    
xmlns:rdf=http://www.w3.org/1999/02/22-rdf-syntax-ns#
    
xmlns:content="http://purl.org/rss/1.0/modules/content/">

  <
channel>
    <
title>{exp:xml_encode}{weblog_name}{/exp:xml_encode}</title>
    <
link>{weblog_url}</link>
    <
description>{weblog_description}</description>
    <
dc:language>{weblog_language}</dc:language>
    <
dc:creator>{email}</dc:creator>
    <
dc:rights>Copyright {gmt_date format="%Y"}</dc:rights>
    <
dc:date>{gmt_date format="%Y-%m-%dT%H:%i:%s%Q"}</dc:date>
    <
admin:generatorAgent rdf:resource="http://www.pmachine.com/" />

{exp:weblog:entries weblog="{master_weblog_name}" limit="10" rdf="off" dynamic_start="on" disable="member_data|trackbacks"}
    
<item>
      <
title>{exp:xml_encode}{title}{/exp:xml_encode}</title>
      <
link>{title_permalink=weblog/comments}</link>
      <
guid>{title_permalink=weblog/comments}#When:{gmt_entry_date format="%H:%i:%sZ"}</guid>
      
<description><![CDATA[{summary}{body}{extended}]]></description>
      <
dc:subject>{exp:xml_encode}{categories backspace="1"}{category_name}{/categories}{/exp:xml_encode}</dc:subject>
      <
dc:date>{gmt_entry_date format="%Y-%m-%dT%H:%i:%s%Q"}</dc:date>
    </
item>
{/exp:weblog:entries}
    
</channel>
</
rss>
{/exp:rss:feed} 

Load the New Embedded Templates
The weblog/index and weblog/comments templates share some right-column elements, so I’ve pulled these out and saved them as embedded templates. Save all of these in the same Template Group as your existing embedded templates.

Weblog Embedded Template – Weblog Categories
Here’s the code for a new embedded template that will display our weblog categories.  Save this template with a name of weblog_categories.
Template Name: embeds/weblog_categories

<h3>Weblog Categories</h3>
<
div class="lcontent">
    <
ul>
         
{!-- Conditional on the list item applies an active class to the currently viewed category. --}
        {exp
:weblog:categories weblog="{embed:the_weblog}" style="linear"}
            
<li {if segment_3==category_url_title}class="active_cat"{/if}>
                <
a href="{homepage}/{embed:the_template_group}/category/{category_url_title}/">{category_name}</a>
            </
li>
        
{/exp:weblog:categories}

         {
!-- This conditional will only show when a category has been selected, and allows a user to return to the default of showing all posts on the weblog --}
        {if segment_2
=="category"}    
            
<li><a href="{homepage}/{embed:the_template_group}/">All News Items</a></li>
        
{/if}
    
</ul>
</
div

Weblog Embedded Template – Weblog Monthly Archives
Here’s the code for a new embedded template that will display monthly archive links for our weblog.  Save this with a template name of monthly_archives.

<h3>Monthly Archives</h3>
<
div class="lcontent">
    <
ul>
        
{exp:weblog:month_links weblog="{embed:the_weblog}"}
                
<li><a href="{path="{embed:the_template_group}"}">{month}{year}</a></li>
        
{/exp:weblog:month_links}
    
</ul>
</
div

Weblog Embedded Template – Syndicate Block
Now that we’ll have an RSS feed, we need the site to provide a link to it.  This embedded template will create another sidebar entry for that purpose.  Save it into your embeds Template Group with a name of syndicate_block:

<h3>Syndicate Weblog</h3>
<
div class="lcontent">
    <
ul>
        <
li><a href="{homepage}/{embed:the_template_group}/rss_2/">RSS 2.0</a></li>
    </
ul>
</
div

Weblog Embedded Template – Entry Comments
This template displays existing comments on a weblog entry, and shows the form for users to enter new comments.  More on why I choose to embed this later.  For now, save this into your embeds Template Group with a name of weblog_entry_comments.

Template Name: embeds/weblog_entry_comments

<a name="comments"></a>
<
h3>Comments</h3>
<
div class="comment_entries">
    
{exp:comment:entries weblog="{embed:the_weblog}"}
        
<div class="posted">
            <
strong>#{count}.&nbsp;</strong>Posted by  {url_or_email_as_author} on {comment_date format="%F %d, %Y"}
        
</div>
        <
div class="comment_body">
            
{comment}
        
</div>
    
{/exp:comment:entries}

</div><!-- close comment entries -->
<
div class="comment_form">
    
{exp:comment:form}
        {if logged_out}
            
<p>
                
Name:<br/>
                <
input type="text" class="comment_textbox" name="name" value="{name}" />
            </
p>
            <
p>
                
Email:<br/>
                <
input type="text" class="comment_textbox" name="email" value="{email}" />
            </
p>
            <
p>
                
URL:<br/>
                <
input type="text" class="comment_textbox" name="url" value="{url}" />
            </
p>
        
{/if}
        
<p>
            
Comments:<br/>
            <
textarea name="comment" cols="60" rows="12">{comment}</textarea>
        </
p>
        
{if logged_out}
            
<p><input type="checkbox" class="check" name="save_info" value="yes" {save_info} /> Remember my personal information</p>
        
{/if}
        
<p><input type="checkbox" class="check" name="notify_me" value="yes" {notify_me} /> Notify me of follow-up comments?</p>
        
{if captcha}
            
<p>
                
Enter this word:<br/>
                
{captcha}
            
</p>
            <
br/>
            <
p>
                
Here:<br/>
                <
input type="text" name="captcha" value="" size="20" maxlength="20" style="width:140px;" />
            </
p>
        
{/if}
        
<p><input type="submit" class="submit_button" name="submit" value="Submit" /></p>
    
{/exp:comment:form}
</div

Update Main Navigation
Now that you have a new section of the site implemented, remember to update the embeds/main_nav template.  Mine now looks like this:

<div id="menu">
    <
div class="submit">
        <
ul>
            <
li><a{if '{embed:my_location}'=="home"class="selected"{/if} href="{homepage}" ><span>Home</span></a></li>
            <
li><a{if '{embed:my_location}'=="about"class="selected"{/if} 
href
="/index.php/site/about/"><span>About</span></a></li>
            <
li><a{if '{embed:my_location}'=="products"class="selected"{/if} href="/index.php/products/"><span>Products</span></a></li>
            <
li><a{if '{embed:my_location}'=="services"class="selected"{/if} href="/index.php/services/"><span>Services</span></a></li>
            <
li><a{if '{embed:my_location}'=="weblog"class="selected"{/if} href="/index.php/weblog/"><span>Weblog</span></a></li>
            <
li><a href="#"><span>Contact</span></a></li>
        </
ul>
    </
div>
</
div

Specifying Names with Global Variables
OK, with those new templates loaded you may need to make name or pathing changes required for using them in your environment.

But don’t do that yet.  I’ve made this easier, and want to explain how.  First open the weblog/index template.  See where it has the following code:

{assign_variable:my_weblog="weblog"}
{assign_variable
:my_template_group="weblog"}
{assign_variable
:my_embedded_template_group="embeds"}
{assign_variable
:my_index_template=""}
{assign_variable
:my_comments_template="comments"

What’s that all about?

These are Dynamically Assigned Global Variables.  Review the EE documentation for them.

Don’t let the “Global” world fool you, though.  Like the docs state: “Variables created this way are available for use anywhere within that template.”

Essentially you can think of these as “text-replacement” variables.  As EE parses the template, it will store the text you specify in the “assign_variable” statement, and then anywhere it runs into that variable name in the rest of the code template, EE will swap out the variable name for the text.  For example, we’ve specified “embeds” as the value for “my_embedded_template_group”.  Later in the template, when EE finds:

{embed="{my_embedded_template_group}/logo_title"

EE will substitute the text we specified and see that line of code as:

{embed="embeds/logo_title"

Got it?

Cool.

Why did I use them?  Two reasons:

  • First, to make it easier for you to move these templates into your environment.  Rather than having to edit several lines of code, now you can just make the change in one spot and the rest of the template will use that updated variable value.
  • To get you thinking about more advanced coding methods like this.  Depending on your specific EE project, using things like Global Variables can make it easier to get your work done by centralizing templates that do the same thing but for different areas of your site.

So, take a moment now and edit the values of those variables in both the weblog/index and weblog/comments templates, where appropriate. Once saved, the templates should load and function properly.

Building Links Using a Combination of Variables
With the Global Variables in place, now it’s possible to build links using a combination of true Global Variables, template Global Variables, and content from a weblog entry.  Consider this link:

<a href="{homepage}/{my_template_group}/{my_comments_template}/{url_title}">Read More...</a

Passing Global Variables to Embedded Templates
OK, take a deep breath.  This will be the most complex part of this chapter, and possibly this entire tutorial series. Go do some carbo-loading if need be.  Ready?  OK.

Here’s the situation.  The weblog/index and weblog/comments templates know some things that the embedded templates also need to know.  The embedded templates are building the navigation to the category and archive views of our weblog, which will use the weblog/index template for presentation.  The weblog templates know the name of the weblog needed, the name of the weblog/index template and what Template Group it’s in, because we’ve specified those items as Global Variables.  But we have embedded templates that will also need that information.

What to do?  Well, we could just copy our “assign_variable” code from the weblog templates to the embedded templates.  But that’s not very elegant, and increases the number of places to make edits if those values change.

The other alternative is to combine Global Variables with Embedded Variables.  This way, the variable is specified in the weblogs templates, and then passed into the embedded template for use there.

Now just stop and think about this for a minute.

What we’ll end up with is an embedded template that builds, for example, links to weblog categories.  But the weblog name of where the categories come from, along with the location of the templates it needs to link to, are variables.

What’s this mean?

You will now have a little “category-link-builder” that you could re-use across different parts of a site, even when the weblog is different or the template it’s linking to is different.

I’ve used this approach on Boyink.com where I have four main weblogs (the business blog, Jeep, Bantam, and Photos).  On each of them I wanted category navigation for the bottom of the page. With this approach I have one embedded template that builds that category navigation, and I just send it the necessary weblog name and template names it needs to link to.

Then, for example, when I wanted to pull category descriptions in addition to the category name, all I had to do was edit that one embedded template’s code, and voila - all four weblogs instantly see the update.

So how to do this?  The trick to remember is that in order to pass a Global Variable to an embedded template you have to change its name on the way.  For example, in our weblog/index template we have:

{assign_variable:my_weblog="weblog"

While passing it to the embedded template (category navigation builder), the variable gets its name changed to “the_weblog”:

{embed="{my_embedded_template_group}/weblog_categories" the_index_template="{my_index_template}" the_template_group="{my_template_group}" the_weblog="{my_weblog}"

Then in the embedded template, the new name is used:

{exp:weblog:categories weblog="{embed:the_weblog}" style="linear"

Also note that formatting with quotes, etc., is very picky and particular while doing this.

OK- breathe easy. The hardest part is over.

Again, to summarize, with these templates you should be able to load them up, edit the Global Variables to reflect what you’ve named both the templates and your Template Groups (make sure to edit both the weblog/index and weblog/comments templates) and, once saved, the weblog should function.

The Comments Form
Let’s take a look at the comments form now.  You might be wondering why, since I have only one weblog single view/permalink/comments template, why I choose to embed the part of the page that actually displays the comments (the embedded template called “weblog_entry_comments”).

Mainly because it makes the weblog/comments template a bit shorter and cleaner, and it sets you up well for use with multiple weblogs.  Ever since building Boyink.com in this fashion - where I wanted to have a centralized comments form for use by four different weblogs - I’ve been doing it this way.  Comments are a bit of a pain to layout and style, so only doing it once for multiple weblogs is a nice way to go.

Lesse…what else is there with this chapter.  Oh yea…

Highlighted Category Navigation
Just for fun I used URL Segments along with conditionals to apply an active class to the currently viewed category.

Let’s look at the embeds/weblog_categories template again:

<h3>Weblog Categories</h3>
<
div class="lcontent">
    <
ul>
         
{!-- Conditional on the list item applies an active class to the currently viewed category. --}
        {exp
:weblog:categories weblog="{embed:the_weblog}" style="linear"}
            
<li {if segment_3==category_url_title}class="active_cat"{/if}>
                <
a href="{homepage}/{embed:the_template_group}/{embed:the_index_template}/category/{category_url_title}/">{category_name}</a>
            </
li>
        
{/exp:weblog:categories}
        
         {
!-- This conditional will only show when a category has been selected, and allows a user to return to the default of showing all posts on the weblog --}
        {if segment_2
=="category"}    
            
<li><a href="{homepage}/{embed:the_template_group}/{embed:the_index_template}/">All News Items</a></li>
        
{/if}
    
</ul>
</
div

All this does is compare the third URL segment (which displays the category URL Title for the currently viewed category) to the category_url_title of each category returned by the exp:weblog:categories tag.  When the condition is true, the class of “active_cat” is applied to that category name.

Note that if your URL structure is different (or if EE is installed, a directory down from the root) you may need to change what segment the code looks at.

Also, I’ve used another conditional to display an All News Items link under the category list.  This will only display if a category has been chosen.  Not a big deal - it just flags the user that they are looking at a category view and provides a link that’s a bit more clear than remembering to click the Weblog main navigation item.

Monthly Archives
Aside from our trickery with the variables, the archive links are built using a straightforward implementation of the exp:weblog:month_links tag.

RSS Template
The RSS template is also a straightforward copy/tweak of the template that EE installs with.  I did make the changes required for it to display HTML.

Zzzzzzzz
Still with me?  This was a big chapter, but one with some valuable concepts for developing websites in EE.

The Results
At the end of this chapter you should have a working Weblog section on your site, with the ability to leave comments, view categorized pages, archives, and have a working RSS feed.

 

Category Navigation

<< Previous Entry   

Next Entry >>

 

Previous Comments

Picture of Nate Hamilton

by Nate Hamilton

Date: Wednesday, December 17th, 2008
Comment: #1

Hey Mike -

I figured out how to use javascript to change pages. My problem know is trying to figure out how to send the {url_title} to another part of the page. If you look at “www.lcbcchurch.com/splash2/”, I am trying to send the url_title of the audio cast play link to the player so that it knows which code to look at. I can’t change url’s because I am using javascript to hide and show the pages. Do you have any ideas how to send the url_title to another portion of the current page? Let me know, thanks!

Mike Boyink

by Mike Boyink (Author)

Date: Wednesday, December 17th, 2008
Comment: #2

Sorry…you’re off in a direction that I don’t know much about.  Possibly you could use an embed for the code in that other part of the page, then send it the url title as an embed variable.  Past that, you got me.

Picture of Matthew

by Matthew

Date: Friday, January 2nd, 2009
Comment: #3

Hey Mike, quick question. Was leaving the my_index_template variable empty on the weblog index page intentional? On that same page you are passing an empty variable through to the weblog_categories and monthly_archives embed templates, which is not really nessessary. If I’m correct and not reading it wrong, I think you wanted to put “index” for that value like you did on the comments page. Let me know what you think when you get a chance. We all know you’re a busy man. Thanks for everything. ~M

Mike Boyink

by Mike Boyink (Author)

Date: Friday, January 2nd, 2009
Comment: #4

Yep - it was intentional.  I think it’d work either way, but I choose to leave it off.  EE will assume the index template if you specify just the template group.

I did this (IIRC) so I had the same variables at the top of both the weblog/index and weblog/comments templates in this case.

In practice I actually find that I don’t use template variables in this manner much.  They make the code a bit harder to read, and the copy/paste/repurpose process is easily handled with a good text editor and find/replace.

Picture of Andy Marshall

by Andy Marshall

Date: Tuesday, January 6th, 2009
Comment: #5

when trying to view the RSS pages i’m getting an error message:-

XML Parsing Error: not well-formed
Location: http://dev.moogaloo.com/tutorial/index.php/weblog/rss_2/
Line Number 3, Column 14:  xmlns:dc=http://purl.org/dc/elements/1.1/
——————-^

awesome tutorials btw!

Mike Boyink

by Mike Boyink (Author)

Date: Tuesday, January 6th, 2009
Comment: #6

Hi Andy -

It’s tough to tell what’s going on from the output - try the RSS validator: http://validator.w3.org/feed/ .  Maybe it will provide more clues.

Picture of Andy Marshall

by Andy Marshall

Date: Wednesday, January 7th, 2009
Comment: #7

Hi Mike.
Thanks for the reply - the w3c validator gives the same response, stating “This feed does not validate” pointing to the same line. If I take that line out it then throws the same error for the next one.
Its happened on to rss2 feeds I’ve made now - the one in your tutorial, and the one in my own site… very mysterious.
Might try an atom feed now…
Thanks for the help tho!
Andy

Picture of Andy Marshall

by Andy Marshall

Date: Wednesday, January 7th, 2009
Comment: #8

Atom works fine!
Thanks again.

Picture of Andy Marshall

by Andy Marshall

Date: Wednesday, April 8th, 2009
Comment: #9

I’ve come out of a web design agency that made its own CMS and plugged it into every site and since going freelance have had to find my own CMS solution - I initially thought that too, and then asked a friend who also got made redundant at the same time and he pointed out that they charged 4 times the cost of an EE license for a CMS and EE does more!

Picture of billseymour

by billseymour

Date: Saturday, May 2nd, 2009
Comment: #10

Excellent tutorial. One suggestion: there is a lot going on here, a lot of coding/copying (for some) before knowing how tangled up things might have gotten. So I would suggest breaking tutorial 16 into two or more parts, where each part could have an interim ‘up to here’  stopping point to check one’s progress. Appreciate the good work.—Bill

Picture of Derek

by Derek

Date: Wednesday, June 24th, 2009
Comment: #11

Great tutorial.

I’m using this part of the tutorial to list a number of case studies on one page. On the index page, I’m able to list all title links in the main section as well as in a side bar. Unfortunately, when I click on a case study link to view the information (like the comments page), the links in the side bar only show the title/link of the current case study. Is there a way to have all links shown in the side bar on the comments page like on the index page?

I hope I was clear enough…I apologize in advance for any confusion.  :-)

Mike Boyink

by Mike Boyink (Author)

Date: Wednesday, June 24th, 2009
Comment: #12

Hey Derek -

This is a T-shirt moment…every EE developer is struck with this one at some point…;)

Add “dynamic=“off” to the weblog:entries tag in your sidebar.

Picture of Derek

by Derek

Date: Wednesday, June 24th, 2009
Comment: #13

Thanks! That worked perfectly.

Picture of Efraín Bárcena

by Efraín Bárcena

Date: Saturday, July 4th, 2009
Comment: #14

Hi Mike,

I want to incorporate an article image on the the full article view. I created a custom field called article_image and my article content filed formatting is set to xhtml to automatically keep everything looking nice when the post has multiple paragraphs.

The problem is that I don’t know how to put the img scr tag inside the first set of <.p></p.> generated by the article content field.


{exp:weblog:entries weblog=”{my_weblog}”}
<h3>{title}</h3>
<.p><img scr=”{article_image}” class=“left” >{body}
{/exp:weblog:entries}

this generates this:

<h3>Title</h3>
<.p><img scr=”{article_image}” class=“left” > <.p>Paragraph One</p.> <.p>Paragraph Two</p.>

How can I get rid of the the first <.p> that {body} tag is generating??? I know there a backspace=”” but that will only apply to the last </p.>.

Can the html strip plugin do the trick or is there a better approach to accomplish this??

Thanks and Happy 4th of July!!

Mike Boyink

by Mike Boyink (Author)

Date: Monday, July 6th, 2009
Comment: #15

Hey Efrain -

Any time you need to do this sort of thing plug-ins are the place to look.

Off the top of my head I don’t think strip HTML can do just the first paragraph - but could be wrong there.

Picture of Andy Marshall

by Andy Marshall

Date: Monday, July 6th, 2009
Comment: #16

You could scrap the {article_image} field and just place the image into {body} via the image upload button.
Thats the only solution I can think of.

Picture of Efraín Bárcena

by Efraín Bárcena

Date: Monday, July 6th, 2009
Comment: #17

Thanks for the tip Andy. The problem with that is that I don’t want the image to appear on my latest blog entries displayed on the home page. That’s the reason went for the article_image field.

I’m starting to think that the only solution is to create a div with a left float class to hold the image.

You guys have any other suggestions??

Mike Boyink

by Mike Boyink (Author)

Date: Monday, July 6th, 2009
Comment: #18

Another option would be to create a specific field for the article’s first paragraph.

Otherwise this feels like a spot where some crafty jQuery might work as well.

Picture of Efraín Bárcena

by Efraín Bárcena

Date: Monday, July 6th, 2009
Comment: #19

Thanks Andy & Mike,

This are both good suggestions. I’ll create the summary custom field for the first paragraph using the conditional Andy suggested. This will definitely work.

Man.. I can’t believe I didn’t think of such a basic solution.

Thanks for the help guys.

Picture of Juliano Moreira

by Juliano Moreira

Date: Tuesday, July 7th, 2009
Comment: #20

Mike, I’ve got a quick question for you. On the weblog/index under <div class=“entry”> where it says {summary}{body}{if extended}, if I remove the {body} and the {if extended} from the the article shows up nicely as long as I have some text in the summary but If I leave like you have in your example it doesn’t work. What happens is the whole {body} text shows up along with the read more link which it doesn’t make sense. I’m assuming you want to have an excerpt of the text linking to the article. Did I do something wrong here? I’ve inspected the code looking for a mistake but I haven’t been able to identify it. Thanks for you help!

Mike Boyink

by Mike Boyink (Author)

Date: Tuesday, July 7th, 2009
Comment: #21

Hi Juilano -

This code assumes that if you want an excerpt linking to the full article, you’d put the excerpt in the Summary field and the rest of the text in the Extended field.

The conditional around the Extended creates the Read More link only if there is text in the Extended field. 

All content in the Body field will render on the index template.

Picture of Juliano Moreira

by Juliano Moreira

Date: Tuesday, July 7th, 2009
Comment: #22

Thank you Mike! It makes more sense now. I’m new to EE but it’s been a lot of fun for the past 2 weeks. Is there anything else that you’d recommend to learn EE?

Mike Boyink

by Mike Boyink (Author)

Date: Tuesday, July 7th, 2009
Comment: #23

Yes - all the paid content here on Train-ee…;)

Picture of Forex

by Forex

Date: Sunday, July 19th, 2009
Comment: #24

Excellent job explaining some pretty complicated stuff.  You make it look so easy lol.

Picture of Webdesign Brno

by Webdesign Brno

Date: Sunday, July 19th, 2009
Comment: #25

Thank you for this, especially for providing the code as well, for those of us that learn via cut and paste!

Picture of Bruce Floyd

by Bruce Floyd

Date: Tuesday, August 4th, 2009
Comment: #26

On this page, you wrote:
Let’s look at the weblog/categories template again:

I believe you meant to write:
Let’s look at the weblog_categories template again:

REALLY loving these tutorials. Thanks!

Mike Boyink

by Mike Boyink (Author)

Date: Tuesday, August 4th, 2009
Comment: #27

Thanks Bruce - good catch.

Picture of Brianne C

by Brianne C

Date: Thursday, August 27th, 2009
Comment: #28

Another fantastic tutorial. I can’t begin to count the number of hours you have saved me. (Not to mention my level of sanity!)

Thanks again for another helpful bit of code.
*cheers*

Picture of Nathan

by Nathan

Date: Thursday, November 5th, 2009
Comment: #29

Is it possible to have a post entries have an image on the post summary. The summary being the intro to each post entry which leads to the full post.

I am looking to get a layout like the products were. I can adding images to categories is easy, is it the same for a blog entry?

I am also going to user the categories as the main navigation, as the site will basically be one full blog.

Mike Boyink

by Mike Boyink (Author)

Date: Thursday, November 5th, 2009
Comment: #30

You can put images in any weblog field using the File Upload process.

Picture of Lisa

by Lisa

Date: Saturday, November 7th, 2009
Comment: #31

I was wondering if it is possible to set up a page that would enable a user to upload an item with image, descripion etc to a particular category from the front end without using control panel??I am trying to figure out how to do this and then my project will be finished!

Thanks
Lisa

Mike Boyink

by Mike Boyink (Author)

Date: Saturday, November 7th, 2009
Comment: #32

Hi Lisa -

Since that’s not a question directly relating the tutorial here it’s probably best asked in the support forums on ExpressionEngine.com

Picture of dobbindode

by dobbindode

Date: Monday, November 16th, 2009
Comment: #33

Sorry man, the link you posted to www.expressionengine.com doesn’t work for me… Maybe it’s just a problem of my corporate proxy but anyways maybe there is an alternative one? Thanks in advance

Picture of Nathan

by Nathan

Date: Thursday, November 26th, 2009
Comment: #34

Hi.

Having the issues some may have had with the RSS feed, i figured the issue out.

On line: 3, 4, 5 and 6, after the ‘=’ the url needs to be in quotes “”, just how line 7 is

Picture of Oliver

by Oliver

Date: Saturday, March 6th, 2010
Comment: #35

I am using the latest version of ExpressionEngine v2.0.1 Build 20100215.

For some reason, the global variables aren’t being properly assigned:

{assign_variable:my_weblog=“weblog”}
{assign_variable:my_template_group=“weblog”}
{assign_variable:my_embedded_template_group=“embeds”}
{assign_variable:my_index_template=”“}
{assign_variable:my_comments_template=“comments”}

Instead, viewing the page in a browser just displays the above text as HTML.

Did I miss a step?

Thank you,

Mike Boyink

by Mike Boyink (Author)

Date: Saturday, March 6th, 2010
Comment: #36

This wasn’t written for EE 2. See the EE docs and changelog for changes to the tagset.

Picture of Marco

by Marco

Date: Tuesday, May 11th, 2010
Comment: #37

Hi Mike and everybody,

I had some problems with the rss2 template (XML Parsing Error: not well-formed);

I found this resource I’d like to share (it works):

http://23rdworld.com/2009/12/23/how-to-fix-your-expressionengine-rss-template/

Marco

Picture of Matt

by Matt

Date: Sunday, June 13th, 2010
Comment: #38

Hi Mike,

Great tutorial! One question though. I cannot get the comments to work…
The submit comments form (Name, E-Mail, URL, Comment) appears (in Firefox and Chrome but only the comment box in Safari). But when I try to submit a comment EE gives me this error:
“You are not authorized to perform this action”

I set “allow comments” to Yes but still no success…
I also set that no registration is required to post a comment… still no success…

I used your approach on the site I am building now for a health spa. I used it to create a guestbook too where I get the same error when I try to submit comments…

What do you think? What might be the problem?

Thanks for the great tutorial series anyway! Will buy some of your screencasts soon!

Best Wishes,
Matt

Mike Boyink

by Mike Boyink (Author)

Date: Monday, June 14th, 2010
Comment: #39

Make sure you aren’t submitting a duplicate comment - ie “test comment”. 

EE will see that as spam.

Picture of Matt

by Matt

Date: Monday, June 14th, 2010
Comment: #40

Thanks Man! That wasn’t the issue though.
I figured it out few hours ago.
It was this security setting:
Require IP Address and User Agent when receiving comments?
I had to set this to No, and now it works!

Mike Boyink

by Mike Boyink (Author)

Date: Monday, June 14th, 2010
Comment: #41

OK - that’s where I was going next.  Glad you got it sorted.

Picture of square peg web

by square peg web

Date: Thursday, June 17th, 2010
Comment: #42

The submit comments form (Name, E-Mail, URL, Comment) appears (in Firefox and Chrome but only the comment box in Safari). But when I try to submit a comment EE gives me this error:

Mike Boyink

by Mike Boyink (Author)

Date: Thursday, June 17th, 2010
Comment: #43

Are you logged in in Safari?

Picture of Purvi

by Purvi

Date: Monday, August 9th, 2010
Comment: #44

Hi,

i am new to EE &your; tutorials have helped a lot to understand basic concepts. I am facing a strange problem with variable declaration. I want to have store cat_id in temp. variable & then assign it to category_archive’s show parameter.

But I am not able to set this variable. Even the basic
{assign_variable:cat_id=“64”}
is just printing the same line on browser. It feels like its nor parsing the value.

Can you please point out where i m going wrong?

Thanks
- Purvi

Mike Boyink

by Mike Boyink (Author)

Date: Monday, August 9th, 2010
Comment: #45

Hi Purvi -

Are you using EE 2? If so assign_variable is now preload_replace.

Also make sure you aren’t getting smart quotes.

If that doesn’t help then a post in the tech support forums is in order..;)

Mike Boyink

by Mike Boyink (Author)

Date: Tuesday, August 10th, 2010
Comment: #46

Hey Purvi -

Throw a post in the EE forums—I typically hang out there a little each day but importantly there are folks with more PHP background than I have.

Make sure to include a description of your goals - many times there is an easier way to do something in EE than resorting to PHP.

Picture of Purvi

by Purvi

Date: Tuesday, August 10th, 2010
Comment: #47

Hi Mike, Thanks for your reply. After I posted this question, I went through couple of your more tutorials & found out that even assign_variable is not actual variable declaration but its more like “const”(constant)

Is there any way to have actual variables? I also tried assigning value to php variable.. but no success.

Can you please help me with this?
Thanks once again
- Purvi

Mike Boyink

by Mike Boyink (Author)

Date: Wednesday, August 18th, 2010
Comment: #48

Uh, a couple of comments:

#1. EE 2 is a released product, officially out of beta as of July 12

#2. The Word Limiter plugin will work with any content field, regardless of if commenting is used, or enabled.

#3. One single view template could be used for entries with or without comments.

Picture of sandy

by sandy

Date: Thursday, October 7th, 2010
Comment: #49

Hi,
You aren’t exiting “main” when you call “other_function”, so when “other_function” returns, the values stored in x and y are unchanged. You don’t exit “main” until the program terminates. (However, if you have a memory (stack) error in “other_function”, that could cause the values stored in x and y in “main” to be clobbered.) Thanks.

Picture of Binod Chourasia

by Binod Chourasia

Date: Wednesday, November 3rd, 2010
Comment: #50

hi, Mike
  Im new here, so i must get help…..........

Picture of nathan

by nathan

Date: Wednesday, November 24th, 2010
Comment: #51

hi mike, can i implement the link to my rss feed like


“<link rel=“alternate” type=“application/rss+xml” title=“Your Blog Title” href=“your actual RSS or Atom Feed URL here!” />”

thanks

Mike Boyink

by Mike Boyink (Author)

Date: Wednesday, November 24th, 2010
Comment: #52

Yes.

Picture of Gary

by Gary

Date: Saturday, January 15th, 2011
Comment: #53

Hi,

Can you show me any resource on EE Blogs anywhere? I tried searching the User Guide, and other online resources, but Couldn’t find any.

Regards,

Gary.

Add Your Comment

Commenting is not available in this channel entry.

Unless otherwise stated all content is © Michael Boyink of Train-ee.com & Boyink Interactive. Please don't steal - I've got kids to feed...

dy>