WordPress.org

Ready to get started?Download WordPress

Forums

Pods - Custom Content Types and Fields
[resolved] Are Magic Tags recommended? (4 posts)

  1. maiki
    Member
    Posted 8 months ago #

    I've been seeing notes in the changelog about moving the templates into a file. I started doing that for a current project, and it worked fine for my purposes, I put in a template for the CPT in the child theme.

    However, I had to add another CPT, and suddenly I realized I would rather have one tempalte that pulls in the header and footer and use pods_content to pull in the pod templates for the different post types. I only need to have the one file, and honestly, using magic tags is way easier to create concise output.

    I get that it is stored in the database, and all that entails. I haven't tried any performance tests, and I *would* like to keep my templates in vcs. Please let me know what the recommended deployment is, and what I should consider when deciding. Thanks! ^_^

    http://wordpress.org/plugins/pods/

  2. Josh Pollock
    Member
    Plugin Author

    Posted 8 months ago #

    It depends on how you like to work, both are valid approaches. Pods Templates are theme independent and allow you to use magic tags. But, you see the downside re:version control.

    Templating systems like Pods Templates are an excellent way to keep your php and your html separate, which is a great way to work. For that reason I've been playing with the idea of using Pods Templates in a WordPress template using pods::template().

    For example, here is a simple function to filter the_content for a CPT so it returns a template and then the content:

    function slug_cptSlug_content_filter($content) {
    	if ( get_post_type() == 'cptSlug' ) {
      		$obj = pods('cptSlug', get_the_id() );
    		return $obj->template('template_name').$content;
     	}
     	return $content;
    }
    add_filter( 'the_content', 'slug_cptSlug_content_filter' );

    You can also just use pods::template() directly in your single-{post-type}.php template or wherever.

  3. maiki
    Member
    Posted 8 months ago #

    Josh, two things. First, thanks for helping me in #pods the other evening. I ended up switching to magic tags, but I was able to figure out a solution to loading the image ({@logo._img.medium}).

    Secondly, that is killer! And I hope that makes it up as an example in the documentation.

    I don't know PHP, but I probably have an intermediate understanding of WordPress template tags. I have a decent grasp of many Pods tags, but only those that have examples or are mentioned in the odd tutorial. I've used Pods in nearly every project in the last six months, and I am looking forward to snippet/pattern sharing. Which would make a great site... ^_^

  4. Josh Pollock
    Member
    Plugin Author

    Posted 8 months ago #

    @maiki Always glad to help.

    Did you see all of the fun magic tags I added in the additional information section of the magic tags docs page? http://pods.io/docs/build/using-magic-tags/

    My mind was fairly blown when Scott pointed that those tags were possible:)

    If you are not comfortable with php, but can do what you need to with magic tags then I say use Pods Templates. There are some limitations, but with a little hacking of your theme files you can do pretty much anything.

    The idea of a Pods code snippet sharing site, using something like Capsule or Pears has been in the back of my mind for awhile, but I just don't have the time to set it up. Might be a fun project for someone to do for the community...

Reply

You must log in to post.

About this Plugin

About this Topic