The MU forums have moved to WordPress.org

Adding a template across all themes? (15 posts)

  1. jwack
    Member
    Posted 14 years ago #

    I am pondering some ideas, and was wondering if anyone had a good solution.

    Here is what I need. I need to have an easy way for all bloggers to be able to write a "how to" type post in a certain format.

    It would basically be a list of items, each item would include an image floated left, a title with a smaller caption floated right, and a description.

    As far as I know there is no way for a user on my site to add the styling and such to achieve that basic layout. I am trying to come up with a good way to provide them with a "template" that comes with some basic styles. Obviously this would need to be available regardless of their theme.

    I know tinyMCE has a template feature but I'm not sure about doing that. I could maybe just make a FAQ and provide them the code but then I would still have to place the styles some where?

    Any ideas would be great!

  2. ancawonka
    Member
    Posted 13 years ago #

    Hmm, this is an interesting question...

    You could develop a plugin that provided this functionality. For example, it would have form fields for the image, caption, and description. When a user saved their content, a post would be created.

    The advantage of using a plugin is that you can overload some of the editor functions, and load your own custom styles when creating or displaying the post of that type.

  3. jwack
    Member
    Posted 13 years ago #

    Hmmm. I didn't think about trying to create a plugin, probably because I would have no idea how to do so. I really like this idea.

    You know of any good tutorials on making a plugin that would cover that functionality? Thanks for the idea, I will search around for more info.

  4. andrea_r
    Moderator
    Posted 13 years ago #

    I;d do it with shortcodes. Write the plugin to spit out what you want, user adds a shortcode with their own values. Presto. :)

    Otherwise, you literally have to make a custom page template for every single one of your themes.

  5. jwack
    Member
    Posted 13 years ago #

    I am trying to do a basic example from the codex using a simple shortcode to learn these bad boys.

    function caption_shortcode( $atts, $content = null ) {
       extract( shortcode_atts( array(
          'class' => 'caption',
          ), $atts ) );
    
       return '<span class="' . esc_attr($caption) . '">' . $content . '</span>';
    }
    add_shortcode('caption', 'caption_shortcode');

    and then in the admin (in html mode)...

    [caption class="headline"]My Caption[/caption]

    This should post <span class="headline">My Caption</span>

    But its giving me an empty class, headline does not appear? I am using MU and checked kses.php to make sure class is allowed for the span tag. Any ideas?

  6. jwack
    Member
    Posted 13 years ago #

    Someone correct me if I'm wrong but the codex has a bit of a misprint. In the return line, it should say esc_attr($class) and NOT esc_attr($caption).

    This should be changed, since it was the first time I've ever tried shortcodes and I'm a php newb it took me 2 hrs to find this :-)

  7. andrea_r
    Moderator
    Posted 13 years ago #

    You're allowed to edit the codex. :) everyone is.

    yes, someone will check it over later.

  8. jwack
    Member
    Posted 13 years ago #

    Cool, I didn't know that!

  9. jwack
    Member
    Posted 13 years ago #

    OK, I am still working on this. I am trying andrea_r's solution. So far I have made the shortcode piece. I put the function in functions.php of my theme to test it, and then in a post entered all the data using the shortcode. It is working.

    I am confused on the

    "Write the plugin to spit out what you want"

    part. So far I have created a plugin that just just does the version check deal but I am not sure what this plugin needs to do exactly?

    I am guessing it would need to write the shortcode function into other blog users functions.php or something like that?

  10. jwack
    Member
    Posted 13 years ago #

    I tried making a plugin that attached the shortcode to the end of a post but I couldn't get the value entered in the shortcode to carry over, it just posted the default values.

    Any help in the right direction would be great.

  11. jwack
    Member
    Posted 13 years ago #

    Nevermind, I got it! Works awesome. Plugin is set to be active when users sets up a blog (i may change that). Then they just enter the content on a post using...

    [shortcode value1="something" value2="something" value4="something"]
    Main content here...
    http://www.linkToVideo.com (which automatically embeds)
    [/shortcode]
    ...
    ...

    When they submit the post the shortcode function filters it and displays it in the correct html formatting, which is styled by a unique style sheet uploaded by the plugin.

    O ya!

  12. lindsayanng
    Member
    Posted 13 years ago #

    I'd love to pick your brain over this if you don't mind. I"m trying to make a stupid simple content system like yours. Its basically for a bunch of ludites who dont know anything about computers and I will need to make stuff like this FOOL PROOF like you have.

    Any thoughts on uploading your plugin for download?

    i was going to create a page template and set the template as the default and then require an "extra field" and make them stick a url of the image I need them to upload there.. then i would design the page template to pull the extra field contents into an image wrapper that aligns a certain direction

  13. DeannaS
    Member
    Posted 13 years ago #

    The 3.0 way to do all this would be with custom post types. Basically, you can drop out everything in the "normal" post/page interface and have whatever fields you want. So, you could have an "image" field and a "title" field. I'm messing around with them right now and they're pretty darn cool.

  14. lindsayanng
    Member
    Posted 13 years ago #

    Deanna, Just for kicks, have you ever seen the BP gallery addon from buddydev? Its pretty genius.. it basically lets people have a facebook style photo gallery!

  15. DeannaS
    Member
    Posted 13 years ago #

    No, I really haven't played with buddypress much at all.

About this Topic