Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums Other Backend-editable footer sentence

  • This topic is empty.
Viewing 8 posts - 1 through 8 (of 8 total)
  • Author
    Posts
  • #24128
    Camtech
    Member

    I have a wordpress 2.7 site on which I am trying to create a small sort of About Us sentence in the footer (much like Chris’s About the Author in the footer of CSS-Tricks). Now this itself is not hard at all, but I would like to be able to edit what this About Us thing says from within the wordpress backend. My initial reaction was to make a plugin, which I have nearly got working.. but the plugin is not my question yet. I am wondering if anyone has a better idea on how to go about doing this. If a plugin is the best way to go then I’ll post what I’ve done so far, it just seems that there might be an easier way to do this.

    #54174
    ikthius
    Member

    from within wordpress, I think it would have to be a plugin,

    I can’t see anything in wordpress that will work with the footer from within wordpress, as in the back end.

    why would you not want to change the footer file and upload? why would you want to change the footer so often that you need wordpress?

    #54175
    Camtech
    Member

    Well, if it was for me, I would just change the file and upload. And actually the editable footer isn’t extremely important as it won’t be changed too often. But, there is a similar sentence in the header which will be changed more often. I was hoping to end up using the same technique/plugin on that too since its basically the same thing.

    #54179
    Camtech
    Member

    I’ve attached what I’ve done so far on the plugin. It works quite well besides that when you Save Changes on the admin page it forwards to the blank options.php with only the footer displayed. I’m sure there is a fix for that, but being my first plugin I’m guessing I just did something wrong.

    I was thinking about plugin vs function.php
    With the plugin, it can be distributed.. because who knows, people might want this sort of functionality in their other pre-downloaded theme.
    But with functions.php it would be theme specific.. which is also okay. But not everyone with a certain theme will need this functionality.

    But for now, I’ll use whatever works. Don’t exactly have to decide on plugin vs functions until later. After it works and if other people actually want it.

    #54218
    Chris Coyier
    Keymaster

    I just tested it out and it’s a little funky, but it works! Activating it did bring me to that blank page. When I save the text, it also brings up a nasty warning on an otherwise white page:

    Quote:
    Warning: Cannot modify header information – headers already sent by (output started at /nfs/c02/h02/mnt/21410/domains/jeffcampana.com/html/wp-content/plugins/editable-template-tags/editable-template-tags.php:11) in /nfs/c02/h02/mnt/21410/domains/jeffcampana.com/html/wp-includes/pluggable.php on line 850

    But… press the back button in the browser and the text DOES save. I’ve used it to control the text in the footer on a new site I built for a friend:
    http://jeffcampana.com/

    #54220
    chazzwick
    Member

    Its quite a long code, but this is what i used to do the same thing for a website recently. The Client wanted a way to put news and traffic updates on their site, and have them update it in wordpress.

    Add this code to functions.php:

    Code:
    ‘The News!’,
    ‘theTraffic’ => ‘The Traffic!’,
    );

    var $options;

    /* Create new control panel function and defines administration menu, and head you do not need to modify anything in this part */
    function ControlPanel() {
    add_action(‘admin_menu’, array(&$this, ‘add_menu’));
    add_action(‘admin_head’, array(&$this, ‘admin_head’));

    /* The following code simply add options. and note the word ‘mytheme’ this can be changed to your theme name actually you just need to make all of them look same. */
    if (!is_array(get_option(‘mytheme’)))
    add_option(‘mytheme’, $this->default_settings);
    $this->options = get_option(‘mytheme’);
    }

    /* This adds administration menu: Under Design, it adds a theme page called Simple Control Panel and also notice how I didn’t change mytheme name */
    function add_menu() {
    add_theme_page(‘Control Panel’, ‘Control Panel’, 8, “mytheme”, array(&$this, ‘optionsmenu’));
    }

    /* Here you put your form CSS. The control panel form has a class of themeform. so Just create your stylesheet here for themeform fields, inputs, etc…I will leave this part for you as its really easy */
    function admin_head() {}

    function optionsmenu() {
    if ($_POST[‘ss_action’] == ‘save’) {
    /* This is just to update the boxes every time we update the form */

    $this->options[“theNews”] = $_POST[‘cp_theNews’];
    $this->options[“theTraffic”] = $_POST[‘cp_theTraffic’];

    update_option(‘mytheme’, $this->options); /* Tells wordpress to update your options.. */

    echo ‘

    Your changes have been saved.

    ‘; /* Displays successful message.. like changes have been saved! */
    }

    /* That is all.. lets print the form to browser */
    echo ‘

    ‘;
    echo ‘

    ‘;
    echo ‘‘;

    echo ‘

    ‘;
    /* Field for theNews */
    echo ‘

    ‘;

    /* Field for theTraffic */
    echo ‘

    ‘;

    /* The default value is Welcome to my blog! but you can always change that..just as a very simple example */

    echo ‘

    ‘;
    echo ‘

    ‘;

    echo ‘

    ‘;

    }

    } /* Quit Control Panel Class. Very important! */
    ?>

    Replace theNews and theTraffic whereever you see them (in your case footersentence and headersentence).

    When you logon to wordpress, you should see a menu called "Control Panel" in the Appearance section. In it will be two text boxes which you can put whatever you want in.

    Now, add the following to any wordpress page (index.php, footer.php etc)

    Code:

    i think this should work

    #54225
    Camtech
    Member

    Yeah, I wouldn’t recommend using my plugin quite yet, it also seems to prevent posting and navigating around some parts of the backend… I obviously did something wrong somewhere. For now I’ll try out what chazzwick has posted and see what I can do with that.

    Edit: It works quite well. Maybe I’ll attempt to convert it to a plugin if chazzwick doesn’t mind. Key word there is "attempt".

    #54137
    chazzwick
    Member

    its not my code, this is where i got it from http://www.webloglines.com/blog/stuff/article/building_a_control_panel_for_your_wordpress_theme.php

    Youd have to ask them

Viewing 8 posts - 1 through 8 (of 8 total)
  • The forum ‘Other’ is closed to new topics and replies.