Need help coding a "Breaking News" image for placement on posts

Discussion in 'Web Design and Development' started by celticpride678, Mar 12, 2010.

  1. celticpride678

    Joined:
    Feb 15, 2009
    Location:
    Boston, MA
    #1
    I need some help coding a "BREAKING NEWS" image that when activated on a specific post, will show an image in the post. I have no idea where to start, but here is what I'm thinking:

    When on the New Post page, the author can check a checkbox that will "activate" the Breaking News feature. I need help making the code for both the New Post page and actually placing the image into the code (I can position it later).

    Does anyone have any ideas? Thanks.

    I'm using the Mystique theme and WordPress 2.9.2

    http://www.itsalltech.com
     
  2. angelwatt Moderator emeritus

    angelwatt

    Joined:
    Aug 16, 2005
    Location:
    USA
    #2
    A piece of this may be done using WordPress's custom fields feature. This will likely need to be created as a plug-in, which can be a pain to develop if you're new to it. You can look through the plug-in directory to see if someone else has already created this type of feature.
     
  3. celticpride678 thread starter Guest

    celticpride678

    Joined:
    Feb 15, 2009
    Location:
    Boston, MA
    #3
    Thanks! That worked perfectly. Now do you know of a code that when a checkbox is checked, it automatically fills in a form? Thanks.
     
  4. angelwatt Moderator emeritus

    angelwatt

    Joined:
    Aug 16, 2005
    Location:
    USA
    #4
    Do you mean like with JavaScript? If so, you can attach a mouse click event on the checkbox, then you just grab the text field and set the text value. Below is some quick sample code. The JavaScript cannot run until after the page is loaded to will need to be added to the onload event.

    HTML:
    <input type="checkbox" name="breaking" id="breaking" />
    <input type="text" name="field" id="field" />
    PHP:
    var chbox document.getelementById('breaking');
    chbox.onclick = function() {
        var 
    textfield document.getElementById('field');
        
    textfield.value 'your value';
    }
     
  5. celticpride678 thread starter Guest

    celticpride678

    Joined:
    Feb 15, 2009
    Location:
    Boston, MA
    #5
    Well, that code wouldn't work for me. What I'm trying to do is setup a checkbox asking the author whether this is breaking news or not, and when the checkbox is checked, it fills in the information into the Custom Field Images widget (which is the plugin I downloaded). Thanks for the help so far.
     
  6. angelwatt Moderator emeritus

    angelwatt

    Joined:
    Aug 16, 2005
    Location:
    USA
    #6
    How doesn't it help? It's got a checkbox and fills a text field when clicked.
     
  7. celticpride678 thread starter Guest

    celticpride678

    Joined:
    Feb 15, 2009
    Location:
    Boston, MA
    #7
    I guess it does help, but do you know how to get it to fill the text field from a plugin on the New Post page?
     
  8. angelwatt Moderator emeritus

    angelwatt

    Joined:
    Aug 16, 2005
    Location:
    USA
    #8
    Show the HTML the plugin outputs that needs filling. Hopefully it has some id attribute to make it easy to grab.
     
  9. celticpride678 thread starter Guest

    celticpride678

    Joined:
    Feb 15, 2009
    Location:
    Boston, MA
    #9
    Here is the code.
     

    Attached Files:

  10. angelwatt Moderator emeritus

    angelwatt

    Joined:
    Aug 16, 2005
    Location:
    USA
    #10
    I'm not sure which fields you wanted to use. I don't see any check boxes, just radio buttons. Below is code that attaches click events to those radio buttons and when clicked will fill out the image field url with a default value. I can't test this code, but should be pretty close.
    PHP:
    function addEvent(eleTypefnuC) {
        if (
    el.addEventListener) {
            
    el.addEventListener(eTypefnuC);
            return 
    true;
        }
        else if (
    el.attachEvent) {
            return 
    el.attachEvent('on' eTypefn);
        }
        else {
            
    el['on' eType] = fn;
        }


    function 
    InitRadioButtons() {
        var 
    radios document.getElementsByName('cfi-align');
        for (var 
    a=0b=radios.lengtha<b; ++a) {
            
    addEvent(radios[a], 'click', function() {
                var 
    textfield document.getElementById('cfi-url');
                
    textfield.value 'your value';
            }, 
    false);
        }
    }
    addEvent(window'load'InitRadioButtonsfalse);
     
  11. celticpride678 thread starter Guest

    celticpride678

    Joined:
    Feb 15, 2009
    Location:
    Boston, MA
    #11
    Thanks, that was it. It needed a little modifying, but I got it. Thanks for all the help.
     

Share This Page