Pacecode Blog Tips, Scripts and More…

1Aug/100

Need RSS feed parser for a wordpress site?

Importing and displaying external RSS feeds on your site is a great way to share your online activity with your visitors. If you are active on Flickr, Delicious, Twitter, or Tumblr, your visitors will enjoy staying current with your updates. Many social media sites provide exclusive feeds for user-generated content that may be imported and displayed on virtually any web page. In this article, you will learn three ways to import and display feed content on your WordPress-powered website — without installing yet another plugin.

  • Importing and displaying feeds with WordPress & Magpie
  • What is magpie?
    MagpieRSS is an XML-based (expat) RSS parser in PHP. WordPress uses Magpie to parse RSS and Atom feeds and display them on your website. Magpie parses feeds for two different WordPress functions.

    • wp_rss() - fetches and parses feeds for instant
    • fetch_rss() - fetches and parses feeds for advanced

    Ref Site: Readmore

    26Apr/0912

    Ajax PHP Flat Calendar – Customizable PHP based event Calendar

    Are you looking for php based calendar script for your site?

    Here is the download link for this calendar. Hope this will help for you!

    Demo: AJAX PHP FLAT CALENDER


    Features:

    1. Ajax based PHP Calendar - No page reloading and Flat type calendar.
    2. Simple in Coding - Used very basic php and ajax script
    3. Easy to customize for your web based php project.
    4. Completely free to download and free to modify this script.
    5. It works with PHP4 and PHP 5

    Installation:

    1. Extract this folder to your server directory.
    2. Point out the directory(ajaxcalender) in your browser.
    3Dec/081

    Problem with transparent image resizing? – PHP

    You will get black background if you resize a transparent image. To fix it, You need set alpha channel imagecolorallocatealpha to 127. With imagecolorallocatealpha, it will allocate a color for an image.

    Usage:
    int imagecolorallocatealpha ( resource image, int red, int green, int blue, int alpha)

    From PHP manual:
    imagecolorallocatealpha() behaves identically to imagecolorallocate() with the addition of the transparency parameter alpha which may have a value between 0 and 127. 0 indicates completely opaque while 127
    indicates completely transparent. Returns FALSE if the allocation failed.

    Before using it, you must set to false the blending mode for an image and set true the flag to save full alpha channel information.

    Example:

    <?

    $newImg = imagecreatetruecolor($nWidth, $nHeight);

    imagealphablending($newImg, false);

    imagesavealpha($newImg,true);

    $transparent = imagecolorallocatealpha($newImg, 255, 255, 255, 127);

    imagefilledrectangle($newImg, 0, 0, $nWidth, $nHeight, $transparent);

    imagecopyresampled($newImg, $im, 0, 0, 0, 0, $nWidth, $nHeight, $imgInfo[0], $imgInfo[1]);

    ?>

    Another way to fix this issue:

    phpThumb() - Resize images on the fly

    Description: phpThumb() uses the GD library  to create thumbnails from images (JPEG, PNG, GIF, BMP, etc) on the fly. The output size is configurable (can be larger or smaller than the source), and the source may be the entire image or only a portion of the original image.

    Download: Download

    Site: phpThumb()

    Demo: Demo

    Installation:

    1. unzip the folder and upload the content into the server
    2. give the correct path of the phpThumb.php and image path as per the following syntax

    Resize Syntax:
    <img src="../phpThumb.php?src=images/watermark.png&bg=FFFFFF&f=png" alt="">
    <img src="../phpThumb.php?src=images/watermark.png&bg=FFFFFF&f=gif" alt="">
    <img src="../phpThumb.php?src=images/watermark.png&bg=FFFFFF&f=jpeg" alt="">

    where the bg=FFFFFF represents the bg color of your transparent image.

    19Oct/080

    Playing with author feature in WordPress and author plug-in list

    If you have a wordpress blog with one or more author, then it is most important to list author details in the wordpress post pages. The followings functions will help you list out author details such as

    • the_author
    • the_author_description
    • the_author_login
    • the_author_firstname
    • the_author_lastname
    • the_author_nickname
    • the_author_ID
    • the_author_email
    • the_author_url
    • the_author_link (Version 2.1)
    • the_author_aim
    • the_author_yim
    • the_author_posts
    • the_author_posts_link
    • wp_list_authors

    Okay, will discuss in detail below,

    the_author

    Description: it displays Author's 'Public' Name

    Syntax: <?php the_author(); ?>

    Example: <p> this post was written by <?php the_author(); ?></p>


    the_author_description

    Description: Displays the contents of the about yourself field in an author's profile (Administration > Profile > Your Profile). About yourself is a block of text often used to publicly describe the user and can be quite long. This tag must be used within The Loop.

    Syntax: <?php the_author_description(); ?>

    Example: <p>Cindy biography: <?php the_author_description(); ?></p>


    the_author_login

    Description: This tag displays the login name of the author of a post. The login is also referred to as the Username an author uses to gain access to a WordPress blog. This tag must be used within The Loop

    Note: It's usually not a good idea to provide login information publicly. But it can be used for some other purposes

    Syntax: <?php the_author_login(); ?>

    Example: <p>Author username: <?php the_author_login(); ?></p>


    The_author_firstname, the_author_ lastname, the_author_ nickname

    Description: The following tags display the name for the author of a post. The First Name field is set in the user's profile (Administration > Profile > Your Profile). This tag must be used within The Loop.

    Syntax: <?php the_author_firstname(); ?>, <?php the_author_nickname(); ?>, <?php the_author_lastname(); ?>

    Example: <p>This post was written by <?php the_author_firstname(); ?></p>


    the_author_ID

    Description: Displays the unique numeric user ID for the author of a post; the ID is assigned by WordPress when a user account is created. This tag must be used within The Loop.

    Syntax: <?php the_author_ID(); ?>

    Example: <a href="/blog/index.php?author=<?php the_author_ID(); ?>">View all
    posts by <?php the_author_nickname(); ?></a>


    the_author_email

    Description: This tag displays the email address for the author of a post. The E-mail field is set in the user's profile (Administration > Profile > Your Profile). This function must be used within The Loop.

    Note that the address is not encoded or protected in any way from harvesting by spambots

    Syntax: <?php the_author_email(); ?>

    Example: <a href="mailto:<?php the_author_email(); ?>">Contact the author</a>
    Secure your author’s email:
    This example partially 'obfuscates' address by using the internal function antispambot()
    to encode portions in HTML character entities (these are read correctly by your browser).
    Note the example uses get_the_author_email() function, because the_author_email()
    echoes the address before antispambot() can act upon it.
    Eg: <a href="mailto:<?php echo antispambot(get_the_author_email()); ?>">email
     author</a>


    the_author_url

    Description: This tag displays the URL to the Website for the author of a post. The Website field is set in the user's profile (Administration > Profile > Your Profile). This tag must be used within The Loop.

    Syntax: <?php the_author_url(); ?>

    Example: <p>Author's web site:
    <a href="<?php the_author_url(); ?>"><?php the_author_url(); ?></a></p>
     


    the_author_aim

    Description: This tag displays the AOL Instant Messenger screenname for the author of a post. The AIM field is set in the user's profile (Administration > Profile > Your Profile). This tag must be used within The Loop.

    Syntax: <?php the_author_aim(); ?>

    Example: <p>Contact me on AOL Instant Messenger: <?php the_author_aim(); ?></p>


    the_author_yim

    Description: This tag displays the Yahoo IM ID for the author of a post. The Yahoo IM field is set in the user's profile (Administration > Profile > Your Profile). This tag must be used within The Loop.

    Syntax: <?php the_author_yim(); ?>

    Example: <p>Contact me on Yahoo Messenger: <?php the_author_yim(); ?></p>


    the_author_posts

    Description: Displays the total number of posts an author has published. Drafts and private posts aren't counted. This tag must be used within The Loop.

    Syntax: <?php the_author_posts(); ?>

    Example: <p><?php the_author(); ?> has blogged <?php the_author_posts(); ?>
    posts</p>


    the_author_posts_link

    Description: Displays a link to all posts by an author. The link text is the user's Display name publicly as field. The results of clicking on the presented link will be controlled by the Template Hierarchy of Author Templates. This tag must be used within The Loop.

    Syntax: <?php the_author_posts_link(); ?>

    Example: <p>Other posts by <?php the_author_posts_link(); ?></p>


    wp_list_authors

    Description: Displays a list of the blog's authors (users), and if the user has authored any posts, the author name is displayed as a link to their posts. Optionally this tag displays each author's post count and RSS feed link.

    Syntax: <?php wp_list_authors('arguments'); ?>

    Example: <?php $defaults = array(
              'optioncount' => false,
              'exclude_admin' => true,
              'show_fullname' => false,
              'hide_empty' => true,
              'feed' => ,
              'feed_image' =>  ); ?>
    By default, the usage shows:
        * Does not display the count of the number of posts
        * Excludes the 'admin' author from the list
        * Does not display the full name (first and last) but displays the author nickname
        * Excludes users with no posts
        * No author feed text is displayed
        * No author feed image is displayed
    <?php  wp_list_authors('show_fullname=1&optioncount=1'); ?>
    


    Author image in every post - Plug in:

    Description:

    Display image (if present) and/or name for the author of a post, or for all authors on the blog.

    for more info and downloads:http://coffee2code.com/wp-plugins/author-images/

    7Oct/080

    Two Frequently used JQuery Plugins – Ajax forms and Image zooming

    SimpleModal Jquery plugin helps you to create Ajax form with style pop up. It is very easy to setup in the web pages. It supports almost alkind of browsers. This download was written in php(contact.php).

    This plugin uses "contact.php" where you need to change your email id.

    Click this demo button to see the DEMO instantly

    For Dot net developers need to change the contact.php according to their needs.

    For more reference and Download link:http://www.ericmmartin.com/simplemodal/


    Image zooming using JQuery


    This Jquery helps you to integrate small magnifier window close to the image or images on your web page easily. It's the best way to display images in incredible detail. Users do not need to click anything - they just move their mouse over the image to see every detail of your product!

    Features

    • Fast - the page loads as normal, then the high-resolution image downloads invisibly in the background.
    • Easy - add it to your website in minutes.
    • Customisable - change the size, position, colors to suit your website.

    FOR MORE DETAILS AND DOWNLOADS: http://www.mind-projects.it/blog/jqzoom_v10

    24Sep/0813

    ADDING ADDITIONAL IMAGES IN THE PRODUCT DETAILS PAGES -Virtuemart tips

    If you are new to the virtue mart shopping cart software, the following steps will help you to add additional product images in Product details page.

    Assumptions:
    You are using,

    • Joomla 1.5 or Joomla 1.0.x
    • Virtue Mart 1.1.0 stable.

    Steps to add additional images in Product details page:

    1. Go  to  virtue mart  admin panel
    2. Choose “choose extended layout” <helps easy navigation>
    3. List out your products.
    4. Click on media button. A new popup will be opened.
    5. Click the new button to add additional images
    6. Choose additional image s as option, give appropriate height and width for the image
    7. Click on save button. That’s all

    I  am not sure about, it will work for lower version of virtue mart also. Please check and gimme a feed back to this post.

    The following pictures help you for easy understanding.

    ImageShack

    ImageShack

    ImageShack

    ImageShack

    ImageShack

    ImageShack

    21Sep/082

    Part of Page refresh using AJAX with timed delay

    <head>
    <script type="text/javascript">
    function makAx() // this function to activate XMLHttpRequest Object
    {
    try
    {
    xm = new ActiveXObject("Msxml2.XMLHTTP");
    return true;
    }
    catch (e)
    {
    try
    {
    xm = new ActiveXObject("Microsoft.XMLHTTP");
    return true;
    }
    catch (e2)
    {
    xm = false;
    }
    }
    if (!xm && typeof XMLHttpRequest != ‘undefined’)
    {
    xm = new XMLHttpRequest();
    return true;
    }
    }
    function showImages()
    {
    if(makAx()) // XMLHttpRequest checked here
    {
    url = "external-page-for-db-query.php"; // this file will contains your db query
    callavail();
    }
    }
    function callavail()
    {
    xm.open("GET",url,true); // This is ajax functionality. It may have true(for synchronous request) or false(for asynchronous request)
    xm.onreadystatechange = cavail;
    xm.send(null);
    }
    function cavail()
    {
    if(xm.readyState == 4) // If ready state reached
    {
    var response = xm.responseText;
    var str = document.getElementById("showResult"); // result of "external-page-for-db-query.php" will come here
    str.innerHTML = response;
    setTimeout("showImages()",1000); // here 1000 represents one second for time delay. showImage() function will be called with the specified time delay
    }
    }
    </script>
    </head>

    <body>
    <div id="showResult"></div> <!–page result will be displayed here–>
    </body>
    </html>