Quantcast

Joel Nagy .com

web technology is a way of life

Archive for February, 2009

MODx: data passing between snippets

I’ve found a little problem with MODx and transferring data to a snippet and using it in a string comparison.  The issue arises when you call a snippet from within a page (in the [*content*] portion).  There is also an issue when passing a MODx var in a snippet parameter.  In order to overcome this issue, I’ve needed to create two snippets, one called within the template and another that can be called in the text of [*content*] and get the data from the first snippet.

1. Create a snippet called [[setup]] with this code:

$modx-vars = Array();
$modx->vars['alias'] = $alias;

2. Create another snippet called [[nav]] which would have code like this that would give a class to a navigation link for example:

$alias = $modx->vars['alias'];
echo $alias == 'index'? ' class="current"': '';

3. Then we’ll need a template with this code:

[[setup?alias=[*alias*]&done]]
[*content*]

Note: In the call to [[setup]] we end with &done since the triple end brackets ] cause a problem of their own.

4. Finally create a page with this content:

[[nav]]

Now you can use the $modx->vars array to pass any data you need from one snippet to others when you need to use that data for actual string comparison, manipulation or usage that would otherwise only be accessible after MODx performs a php eval.

Reblog this post [with Zemanta]
  • 3 Comments
  • Filed under: Code
  • How Does a Visitor Find Their Way?

    A nice continuation from a previous post of leading web visitors is a discussion about how our users find what they want on our sites.  Right now the two most common ways visitors will reach your site is:

    1. Direct: bookmark, typed (first discovered from an ad or friend), or referral link
    2. Search Engine: link to home or deeper page

    These two ways will put people either at your front door or lost in the maze.  So how do you help them find more value in your site or maybe what they really are looking to find.  We have a few options:

    • Main Navigation
    • Search Bar
    • Call To Actions (CTAs)

    These three main ways provide the major ways that should be present on almost every page of your site. Sure this all seems rather simple and straight forward, but let’s dive a little deeper here.

    Main Navigation is just that, the “main” list of pages to start with. NOT every page; NOT your sitemap. Sometimes you can easily scare or confuse someone when you hand them too many options. You can’t guide someone very well when you hand them what’s essentially your sitemap in a dropdown menu format. This should be used as a way to get to the primary sections and possibly a few sub sections that are commonly sought out.

    The Search Bar is your second best tool, as this allows the visitor to feel like they can help themselves and get what they want.  However it’s only useful if they know what search words to use.  And it’s only useful if the pages on your site of course use the words the visitor uses (a puppy is a dog, but a dog isn’t always a puppy, thus the types of words used are very important, but then that’s for yet another post.)

    Third we have CTAs which are designed to attract the eye with bold text or graphics and allow us to drive the user to places we think they’ll find interesting, that are new, or will help us empty our extra inventory. These should not be splattered everywhere and are not a replacement for quality content on those pages.

    So by providing simple navigation, a quality search bar, and useful and sparing CTAs we can provide many helpful ways to guide our users along a path of our choosing (or their own with search) that makes for a better experience.

    Sure these concepts aren’t new, but sometimes they need to be said over and over to make sure we don’t fall into old bad habits.

    Reblog this post [with Zemanta]
  • 0 Comments
  • Filed under: Thoughts
  • What’s that site built with?

    Quite often in my line of work I’m expected to build from an existing web site. A little tech due diligence ahead of time is always nice and helpful. I just found this great site, Sitonomy, which will give you backend data on what a server is currently running. Are they using Apache or IIS, PHP or JSP, Movable Type or WordPress? Sure you can easily see this sometimes through the URL, but if a site uses rewrite urls or friendly URLs certain data isn’t as easily distinguishable. It’ll even pull out things you would need to dig into the actual code to see, such as which JavaScript library or blogging engine is being used, what advertsing networks do they work with. Using Sitonomy makes this easier, as well as putting this tye of data into hands of less technical people that would be lost digging through code.

    Here’s what Sitonomy themselves lists for their own site:

    Name Description
    Infolinks Infolinks, Inc. is a provider of In-Text advertising that enables online content publishers to benefit from premium In-Text ads while keeping most of the

    advertising

    revenue.

    AddThis AddThis is the bookmarking and sharing button.
    Google Analytics Google Analytics is a free service that allows tracking and analysis of your blog visitors (where their come from and what they do on the site.
    Statcounter StatsCounter provides website statistics service that allows detailed real-time visitors tracking and analysis.
    ASP.NET ASP.NET is a web application framework owned and marketed by Microsoft.
    Microsoft-IIS Microsoft-IIS is a set of Internet-based services for servers using Microsoft Windows.
    Reblog this post [with Zemanta]
  • 0 Comments
  • Filed under: General
  • Posting to WordPress via BlackBerry

    Yesterday, I posted my first post via BlackBerry after dealing with a few issues in WordPress that required a little modification to the wp-mail.php file. Seems that HTML emails don’t get through very well. So here are two basic steps to posting via email with your BlackBerry.

    Set up your BlackBerry user account as an Author. From the Dashboard, go to Users and add the email account you use on your Blackberry, your name and a different login and password (you won’t really need these as this account is for email posting) and the Role to Author.  Optionally, after you save go back to the new user and set the Display name as your name, so all posts look the same.

    Now overwrite your wp-mail.php file with this one.

    Here’s the code I changed:

    if ($content_type == 'multipart/alternative') {
    $content = explode('--'.$boundary, $content);
    $content = $content[2];
    $content = explode('Content-Transfer-Encoding: quoted-printable', $content);
    
    // BlackBerry Conversion Code
    $content = $content[0];
    $BODY = strpos($content, '<BODY>');
    if ($BODY !== false && $BODY > 0 && $body === false) $content =     substr($content, $BODY);
        $patterns = array ( '/<FONT FACE\=3D\"Verdana, Helvetica, Arial\"><SPAN STYLE\=3D\'font-size\:12\.0px\'>/',
            '/<\/SPAN><\/FONT>/',
            '/\=[\n\r]+/',
            '/<BODY>[\n\r]+/',
            '/<\/BODY>[\n\r]+/',
            '/<HTML>[\n\r]+/',
            '/<\/HTML>[\n\r]+/',
            '/<BR>/');
        $replace = array ('', '', '', '', '', '', '', '<br />');
        $content = preg_replace($patterns, $replace, $content) . '</p>'; // replace and add trailing P tag
        $content = strip_tags($content, '<img><p><br><i><b><u><em><strong><strike><span><div>');
    } else if (stripos($content_transfer_encoding, 'quoted-printable') !== false) {
        $content = quoted_printable_decode($content);
    }
    $content = trim($content);

    Try it out, let me know if you have any issues.

  • 9 Comments
  • Filed under: Code
  • BlackBerry Storm: And the Beta Culture

    I’ve been using the new Storm now for about two weeks.  It of course has the later bug fixes which help with all the previously known problems that many users have experienced.  For years people have always known that first time out products have flaws.  My father always said to never buy a car the first year its made, they need time to work things out.  Today though with the “eternal” betas of Google we live in a beta culture.  Before Google most beta programs and products were relegated to a select few.  Now everything is beta.

    Is it okay? I love being the first to try out a new beta web site. But I won’t spend money on a beta product. So I waited and here I am now blogging with my BlackBerry Storm, loving the click keyboard, and of course happy with the reliable Verizon service.  Some things are not worth the beta experience.  TiVo first gen users have always complained about that, so our beta culture should be clear now on what it means to have a first gen product.

  • 0 Comments
  • Filed under: Thoughts
  • Here’s a plethora of well designed RSS Feed icons for free!

  • 0 Comments
  • Filed under: Links
  • Conversation Frequency

    In a similar vein to my previous concept of developing a better method for finding relevant products based on quality reviews and ratings I have thought of an idea for how to find relevant “conversations” and information that are available on blogs, forums and similar conversation centers.

    Currently information can be found through keyword searching, by date, or forum entries with recent comments. But none of these really shows true activity. On a blog, the most recent post or the post with the most comments are not neccessarily the ones that truly have the most qualified activity.

    Sometimes a forum post that’s years old will be commented on and rise to the top, a trick that is commonly used to “bump” a post to the top to gain undeserved attention.  Often there are posts on a blog that are heavily trafficed and have many many comments, especially if the post is old.  This commonly leads blogs to not allow comments on old posts.

    I recommend that blogs and forums should have an option to sort entries by activity.  Such a sort would take not just the recency or quantity of the comments but would use them together.  A point system could be used to rank posts based on the how recent the last post was along with how recent that comment was to the previous comments along with comments on comments (if that is a feature of the system.)  Other possible ways to add points to a post could be to add a rating system to posts and comments.

    How to search for content on a blog or forum that is not just “most comments” or most recently commented (this allows for posts that are extremely old but have a lot of comments from showing up high when the conversation is very spread out and allows for the “bump” issue to not be a problem by allowing posts that are just commented on by the poster to bump it to the top), but is more defined such as most frequently discussed.  By this I mean that finding discussions where the content is weighted by time since posted, and time span between posts.  An algorithm could be created based on the weight to determine a point value for the discussion that would then allow you to see what has the highest frequency.  This would allow you to know which conversations are currently very active.  For example if 75% of the comments are by the creator of the post then each point for the comments are low, but if there are considerable comments by others interspersed between the creators comments (thus illustrating a conversation) then the creators comments are weighted higher since they are adding comments of importance.

    I’m sure there are other potential ways to weight posts and comments, but at any rate a system of sorting by activity will allow you to find content that is currently important and has time sensitive relavance which often is quite important in a forum or any sort of social chating environment.

  • 0 Comments
  • Filed under: Thoughts
  • WordPress as a Social Network engine

    BuddyPress is a very interesting plugin for WP MU (actually it is a collection of plugins) that provide profiles, friends, forums, private messaging, activity streams, and of course blogs.  It currently lacks photo albums and other multimedia features.  I think once these features are added this will be a very versatile alternative to other social engines.

  • 0 Comments
  • Filed under: Links
  • In Other News...