views:

44

answers:

4

Hey

I want to create a custom page that has tournament brackets instead of the usual content. I have read some of the Wordpress documentation and found how plugins work and how I add admin pages to administer the page.

My question is: What is needed to create the page itself (and have it listed on the site)? Do I need to create a custom template that has the majority of the work in it, do I need to have the plugin create the page or where do I start?

Also, how do template pages and plugins interoperate? Does WP provide me a reference variable to the plugin or do I have to load it "manually"?

Thanks

EDIT: I think I'll reformulate my question. While the answers have been helpful, they aren't exactly what I've been looking for.

Basically, I want a page where I have some module / code / whatever that controls whatever goes on there. This means I can't just setup a page since then I can only fill in text. I need a page where I can decide what happens when I go to that page, what is written, submits, etc. I am fairly fluent in PHP, just not Wordpress :)

The second part is the admin, where I need a page (or several) to control some of the administration stuff of said page.

I hope this helps with the clarification.

+1  A: 

Hi, once a plugin is activated, you can use it from any new page.

If I were you, I would encapsulate the logic to show the info for the tournament bracket in a plugin. Then I would create a template page specific for the page you need.

You can create a new page with a custom template just the same way you create any page, and choosing a custom template on WordPress' menu. If you followed the standard page template system in WordPress, the template will appear in the "templates" menu.

Fernando
So I would use the plugin to build the admin interface, and use the custom page template to pull out the page itself from the plugin?
Christian P.
Whatever logic you want to change to the system is better encapsulated inside a plugin: You don't change WordPress' core, and you keep it working despite WordPress updates. That said, I don't see why you need a new admin interface for that kind of pages, but it can be done. You should add something to a new Page which the plugin detects (search for the right filter for this) and adds the information you need.
Fernando
+1  A: 

Depending on your exact needs, a plugin might be overkill unless your wanting to provide it for consumption on the net as well. It would definitely be a little more useful as far as separating the login from the template goes, but for personal use it might end up being more work in order to do something that could be handled just as easily by built in functions.

Something like this is exactly what the newer "Custom Post Types" in Wordpress 3.0+ are built for. Using the new functions you can pretty easily build custom submit forms, and these type of submissions are kept out of the main loop by default, so that content is already separated away from normal blog posts. You can add your specific functions into the default functions.php wordpress uses, or separate it out and just include it manually without having to worry about all the hooks and action calls a "plugin" generally requires.

Using a mix of custom post types and templated pages should be just as useful for you as a full blown plugin, and require less overall Wordpress knowledge to implement. I highly suggest checking out what Custom Post Types have to offer, the following links should be useful in getting you started:

http://justintadlock.com/archives/2010/04/29/custom-post-types-in-wordpress
http://new2wp.com/pro/wordpress-custom-post-types-and-taxonomies-done-right/
http://kovshenin.com/archives/custom-post-types-in-wordpress-3-0/
http://kovshenin.com/archives/extending-custom-post-types-in-wordpress-3-0/

Jervis
A: 

Hi @Christian P.: This is an answer I wrote about cloning CrunchBase over on WordPress Answers (which won't be public for another 18 hours or so). It's not written with your question exactly in mind but should be so close that I don't think I need to modify it for you to understand how to apply it.

Use Custom Post Type and Custom Taxonomies

What you want to look at are Custom Post Types and Custom Taxonomies [see this answer I gave on a very similar subject].

Example Code for your Company's Post Type and Taxonomies

With WordPress 3.0 you can create a company custom post type and then one or more custom taxonomies that apply to the company such as category, funding and status. To bootstrap your efforts here's code you can drop in to your theme's functions.php file to get your started:

register_post_type('company',
    array(
        'label'           => __('Companies'),
        'public'          => true,
        'show_ui'         => true,
        'query_var'       => 'company',
        'rewrite'         => array('slug' => 'companies'),
        'hierarchical'    => true,
        'supports'        => array(
            'title',
            'page-attributes',
            'excerpts',
            'thumbnail',
            'custom-fields',
            'editor',
            ),
        )
);

register_taxonomy('company-category', 'company', array(
    'hierarchical'    => true,
    'label'           => __('Categories'),
    'query_var'       => 'company-category',
    'rewrite'         => array('slug' => 'categories' ),
    )
);

register_taxonomy('company-status', 'company', array(
    'hierarchical'    => true,
    'label'           => __('Status'),
    'query_var'       => 'company-status',
    'rewrite'         => array('slug' => 'status' ),
    )
);

register_taxonomy('company-funding', 'company', array(
    'hierarchical'    => true,
    'label'           => __('Funding'),
    'query_var'       => 'company-funding',
    'rewrite'         => array('slug' => 'funding' ),
    )
);

Other Post Types you might want:

If you really want to clone CrunchBase you'd be wanting to create custom post types for each of these (though I'm guess you want something similar but for a different market?):

  • People
  • Financial Organizations
  • Service Providers
  • Funding Rounds
  • Acquisitions

Company Listing Page

For your company's listing page (like this one on CrunchBase) I'd probably create a WordPress "Page" called "Companies" (imagine that!) and then use a post list shortcode plugin like List Pages Shortcode (if you use that one you will need to make a one-line modification to support Custom Post Types like I show here.)

With that plugin and modification you can add the following text to your "Companies" Page and it will list out all the companies in a bulleted list on that page which you can style with CSS:

[list-pages post_type="company"]

Company Specific Layouts

Then for a custom layout for each company you can make a copy of the theme template file single.php and name it single-company.php and make whatever modifications you want to the layout there.

User Company Submissions

And if you want to let people submit companies consider using Gravity Forms (not an affiliate link; US$39 per site license and worth every penny.)

If you need more...

There's more I'm sure but that will get you most of the basic functionality you need. If you need more, ask another question here on WordPress Answers!

Hope this helped.

-Mike

MikeSchinkel
+1  A: 

So far answers I've seen are overtly complex. What you should do is simply this:

  1. In WP, create a new page; title it "example" - note the slug it generates. It should be "example" as well, mimicking the title.
  2. Create a file in your active theme called page-example.php - mirroring that slug.
  3. Sandwich your custom PHP with barebones HTML code in page-example.php:

<?php get_header(); ?>

<!-- your custom php code goes here -->

<?php get_footer(); ?>

Depending on your page, you may need to recreate a few div elements, and possibly toss in a get_sidebar()

pp19dd