Page dependant text in WordPress

Discussion in 'Web Design and Development' started by design-is, Mar 26, 2009.

  1. design-is macrumors 65816

    design-is

    Joined:
    Oct 17, 2007
    Location:
    London / U.K.
    #1
    Hi all :)

    I need some advice with regards to WordPress...

    I need to be able to show a small amount of text on all pages, but depending on which page I'm on, the text needs to be different.

    It's a charity website, with areas for different countries, each with their own set of sub pages.

    I need to display an amount raised for each country on the countries home page and sub pages. Ideally, I will be able to position the amount as I see fit and users will be able to edit the amounts easily some how.

    Is there any way anyone can think of doing this? Widgets, plugins, coding?

    I'm not knowledgeable in the ways of php :(

    Thanks in advance for any help!

    /Doug
     
  2. SrWebDeveloper macrumors 68000

    SrWebDeveloper

    Joined:
    Dec 7, 2007
    Location:
    Alexandria, VA, USA
    #2
    Concept (requires knowledge of WP templates and tags, WP functions and core, PHP/MySQL):

    Learn how template tags work in WP. Add a custom tag in whatever templates you desire and wherever you want it positioned. Hack the WP code to query the database with the data you want and parse the template. You'll need to hack the WP admin to add a simple tool to edit the data in the database or write an external tool that does the same thing.

    That's how I'd implement it.

    To actually do it you should request one of the plugin authors or WP hackers to do this on the appropriate WP developer forum if you do not have all the skills I listed in the requirements and nobody responds here for a small contracting job or freebie.

    Sorry, I can't code it for you this time. I don't use WP and this involves hacking core code and templates on the front end which is required.

    -jim
     
  3. design-is thread starter macrumors 65816

    design-is

    Joined:
    Oct 17, 2007
    Location:
    London / U.K.
    #3
    Thanks Jim - your input is always appreciated. I'm finding my way around the WP templates and tags, but the core and PHP/MySQL is where I'm lost.

    I have found a plugin called More Fields which looks promising. I am in a little over my head though, so not sure if I'll figure it out.

    I'm hoping to find a solution to have 1 location to update these amounts and then they would show on the appropriate page. So I could put the UK total raised in one box somewhere and this would appear say at the top right of the UK page and all its sub-pages (except the red nose day one). I'll explain further. Here is the page hierarchy with the totals that need to be on each (and and the ones below until a new one is mentioned):

    # Home - Worldwide Total
    # About Us
    # Contact Us
    # Fundraising
    # Governance
    # Press
    # Privacy Policy
    # Site Map
    # Terms and Conditions
    # Trustees

    # United Kingdom - UK Total

    * Charity Focus
    * Trader Focus
    * Gallery
    * Red Nose Day - Red Nose Day Total
    o Corporate Activities
    o Gallery

    # United States - US Total

    * Charity Focus
    * Trader Focus
    * Gallery

    # Australia - AUS Total

    * Charity Focus
    * Trader Focus
    * Gallery
    * Bushfire Appeal - Bushfire Appeal Total
    o Activity
    o Our Appeal

    # New Zealand - NZ Total

    * Charity Focus
    * Trader Focus
    * Gallery

    # France - FR Total

    * Charity Focus


    Maybe I could create a page and hide it from the navigation and somehow pull the content to display on the appropriate pages somehow? Having trouble getting my head around it lol

    I'll have a good look into 'More Fields'

    Thanks for advice so far! All further ideas welcome!

    /Doug

    -EDIT-

    OK, so, More Fields looks good in the way that I can put a box which lets me choose options on the pages edit area, but I'm not sure how to make those options mean anything. I now have a box which lets me choose which total to put on a page, but I don't know how to make it do anything with anything lol - I think I'm missing something important... I'll let you know how I get on in case it's useful for anyone else...
     
  4. SrWebDeveloper macrumors 68000

    SrWebDeveloper

    Joined:
    Dec 7, 2007
    Location:
    Alexandria, VA, USA
    #4
    That plugin is for your posted blogs only. Not just static data that shows up in any template at any position. Yes, you're seemingly over your head. As I look at your data, and then your comment, "until a new one is mentioned" you're telling me the data is dynamic, to be edited by users, default data added by you, possible calculations involved, etc. This is all highly proprietary and customized, so my original advice stands.

    Here's a nice plugin for creating custom tags complete with multiple parameters for each tag which would work with your heirchy, but it does not address how the data is entered or updated dynamically. Even the author said, "And if you are a PHP programmer you can write your code within a configuration page. This is what I call productivity!" - that's related to the back end tool I spoke of which of course means your project really is a custom plugin or hack, all the way.

    I've got nothing else to add!

    -jim
     
  5. design-is thread starter macrumors 65816

    design-is

    Joined:
    Oct 17, 2007
    Location:
    London / U.K.
    #5
    Ah, indeed.

    The More Fields plugin was suggested to me on the WP support forum, but I didn't think to check if it was applicable to pages - this may be the flaw in my plan that is confusing me.... Further investigation will take place tomorrow...

    Just to clarify, no calculations will be involved, I just want to me able to show a user defined text snippet on several specified pages.

    Will post back when / if I find the solution :)

    Thanks again!
     
  6. design-is thread starter macrumors 65816

    design-is

    Joined:
    Oct 17, 2007
    Location:
    London / U.K.
    #6
    OK, posting again rather than editing because I've come to a solution. Thought I'd post my way around my problem in case it's useful to anyone...

    I'm using a plugin called Page Excerpt to let me add excerpts to pages and using:

    Code:
    <?php if (have_posts()) : while (have_posts()) : the_post(); ?>
    
    		<div id="total">
    
    		<?php the_excerpt(); ?>
    
    		</div>
    
    <?php endwhile; endif; ?>
    I have added the excerpts where I want them and styled as I see fit.

    When it comes to editing them all at once rather than going through page at a time, I've gone about it a bit backwards, but it works. Using this Search and Replace plugin, we can easily change the relevant amounts when needed throughout the excerpts only.

    So, maybe not the best solution, but it works until we find something better!

    Cheers for advice / pointers! :)

    /Doug
     

Share This Page