WordPress.org

Ready to get started?Download WordPress

Forums

What would you do? (3 posts)

  1. Adam
    Member
    Posted 1 year ago #

    I essentially am stuck on making the loop Object oriented for my framework, that is putting it in a loop. I have the core idea down, How ever as you will know, you should always separate your "view" from your logic. with that type of MVC logic in mind, how can you take the loop and make it OOP? I find I am echoing things inside my functions with in the class - which is the part I am saying is wrong.

    I have a sample of my work on gist with an example of how to use it. I would like the communities feed back.

    The lines I am most concerned about is 75 and 78 - This is not best OOP logic.

    Gist Example of OOP loop

    Keep in mind this is a work in progress.

  2. catacaustic
    Member
    Posted 1 year ago #

    To keep content and code separated, set up a template file in your theme. Then in your object, you can set up whatever variables are needed. Once youv'e done that, use include() to read the template file into the objects function and it will be output as you're expecting. That way you have the code in one place, the template in another place (which lets it be changed a lot easier), and you get to keep your OO code.

  3. Adam
    Member
    Posted 1 year ago #

    Thanks I'll keep that in mind. I am building an entire framework (think of zend - less ambitious) for theme designers and theme framework developers to easily get a project off the ground.

Topic Closed

This topic has been closed to new replies.

About this Topic