Post Data Pull and new blog template

As I have mentioned in prior post. I have been building for years. We built a system called publishtown which is basically the same thing as a wp multisite but cleaner in many ways. I understand the cross compatibility issues that wp plugins run up against but there has to be a better way to build a replicating template website builder.

Here is how I managed it prior. I had folders for the web templates. Then inside this folder I had a user folder similiar to the blogs.dir concept. So I would then use the include path logic built in php and simply check the user folder for the file then the main template folder. This way I could manage the website from the main folder.

In wp since all the data is shoved into the wp_post table it would have to be a database pull unless you built a system that ran off cache files but that is probably not going to happen. So with the database pull from the post table, it could be as simple as this a query join across the site post table and the template post table where page or page_id = ORDER ASC then just pull back the top row. This simply says if this page has been replaced by the site then pull the site page if not then pull the template page.

Now I know the problems with menus and copying data, etc... So here is how I see it working, this will only work if your site menu is not built off the post table. It has to be built through the menu builder. Then you simply do not copy over the post table.

Obviously I lack some understanding here because I have not been using wp that long but the current way of handling replicating websites is a pain. I have thought about running everything through custom page templates and doing it myself and probably will for the short term but I believe that there has to be a better solution than the one currently being developed.

  • PC

    Hello There,

    Greetings and thanks for posting on the forums.

    I am sorry but I don't understand your question here. would you be so kind to elaborate a bit more and in form of questions ?

    As I see you have selected New Blog Templates, and if you want this to allow your users to replicate sites from templates, then I don't foresee any problems with the same. Do you ?

    It should be as simple as creating a template blog on your site and configuring it the way you want your users to be using it and then using NBT to create a template using that and then your users can use that blog as a template on your WordPress Network when creating a site for themselves.

    If there is any particular feature you want to be added to the plugin, here is a thread we are inviting the feedback : https://premium.wpmudev.org/forums/topic/vote-on-the-features-you-like-to-be-there-in-the-plugin

    Cheers
    PC
    Sales &Support

  • Hatchman

    The problem with the new blog template is that it assumes day one that the template is finished. Changes and updates are not easily implemented. Most site templates are never done day one. In fact these templates change over time. It also might be a plan to roll out features and content as part of a retention model. The blog template as I see it does not allow this to occur. Maybe I am missing something and I hope I am. If not then this tool is very limited and a nightmare to update over time.

    One thing that I want to do is have the pages and layout of the website to be controlled by the template but let the end user submit post, listings (directory or classfied) and have an admin where they can manage leads.

    I do have a related question. At what point does the page get pulled from the database in wordpress? Could I create a page template that controls the pull or does it occur prior?

    THKS

  • Ignacio

    Hi @Hatchman.

    What you're asking for is not so easy. Changes after a template is done can create another issues. This is something that users has asked abot but everyone wants it in its own way. Changes could delete posts, pages, menus, users after a site is created and that would carry a lot of new problems. I don't have anything planned about this feature though I'm trying to figure out what would be a good way to achieve that.

    Currently you'll need custom coding for that.

    About your questions:

    How does wordpress know what table to pull from (wp_posts vs wp_2_posts)?

    you need first to set the global variable $wpdb:

    global $wpdb;
    switch_to_blog( 2 );
    $posts_table_ofr_blog_2 = $wpdb->posts;
    restore_current_blog();

    That way you can have the posts table for any blog in your network (this case ID = 2 ).

    Is there a way to change the get_post query without impacting the main code? Inside a theme or plugin?

    I don't understand, why do you want to change the query?

    Where is the get_post called?

    Well, this is a function that you can use anywhere. But I think you're asking about a complex question and you'd better start here:

    http://codex.wordpress.org/Class_Reference/WP_Query

    Regards.
    Ignacio.

  • Hatchman

    Thks @Ignacio

    I am further along since this post. First, I have spent the last 15 years building replicating web systems from one set of code so I do understand the concept. I do not say this in a defensive manner but more in a helping manner. I believe that I am very close to shoving most of these issues. I building a plugin called Hatchman that cleans up some things that are going on with wp that I wish worked differently.

    So with that said, like me explain what I see as a solution. It is the same solution I developed for previous systems except I used folder structures instead of databases to store the pages. Basically it is fairly simple and can be done by modifying the post query or simply call an additional query if the first returns nothing. The problems that I have not solved currently are the relationship to the menu. This will be my next focus.

    So basically the query looks in both the template site table and the site table to pull back the result of the post. It orders by blog_id asc and you use a get_row to pull the top result. This assumes that the template_blog_id is always greater than the site_id. If not then you use 2 queries if result is empty then check template folder.

    Obviously because of the way wp is built there are issues:

    1) You have to use page name in the query instead of id because of the possible overlap.
    2) You have to create a custom menu at the template level and copy this over to the site.
    3) You can not copy over the page and post data to the sites unless you want to give them access to change this content.
    4) The sites you can build and maintain are not as flexible with as many editing features for the end user.
    5) Issues not yet foreseen,,,

    I will return working on this tomorrow and hope to have some of these issues resolved. I do see the problems and the complications. I tend to not want to build a system based off updating everywhere, everytime. I want a simpler and more elegant solution. As I under the queries and how to modify them without impacting the overall functionality then I will be able to accomplish many of these tasks.

    One problem I see with the plugin concept is a lack of cohesiveness between these apps and a incompleteness with the individual plugin. I will example further during our thursday live support sessions.

    Best Regards
    @Hatchman

  • Alexander

    Hi @Hatchman,

    I had some thoughts on this.

    The problem with the new blog template is that it assumes day one that the template is finished. Changes and updates are not easily implemented. Most site templates are never done day one. In fact these templates change over time. It also might be a plan to roll out features and content as part of a retention model. The blog template as I see it does not allow this to occur. Maybe I am missing something and I hope I am. If not then this tool is very limited and a nightmare to update over time.

    This plugin was originally designed with the assumption that you're working with a finished product, or at least something that is shippable.

    New Blog Templates is mainly intended for services that rely on provisioning new sites to meet certain criteria. After the site is created, the user will be responsible for maintaining it.

    Take a look at Edublogs. Once a user signs up, the product is essentially handed to them for use. Why at this point would we want to make incremental modifications to this new site's content?

    The responsibility of New Blog Templates is simple: to provision initial content I don't see how it fails to do that.

    I totally agree that often a template is never finished, but then would it not be easier to make these global changes directly in plugin or theme code rather than the database?

    Even if you were to handle the incremental updates somehow, why would you want to pollute the database with mass amounts of duplicate content?

    I think the problem you're presenting is a bit outside the scope of what New Blog Templates is meant to solve. A better way to solve this would be using template functions in a theme or plugin that simply reference data from another site.

    Best regards,

  • Hatchman

    I hear what you are saying and because of the way that wp handles data, I do see the problems. There are ways to solve these limitations and I am working on them but I thought it would be nice to include inside the template made to manage and distribute this content.

    Replicating website systems are sometimes not intended for end users to change most of the content (pages). The purpose of the site is to provide an organizational network of users who represent that organization through using and promoting the website provide. The template manager provides the tools and content. My example is very similar to this. I have a network of people that we are providing static content (pages). It could be handled through page_templates but not a very elegant solution. Although it is complicated, I have almost completed version of a plugin that accomplishes what I am asking for. There are short comings that I am trying to resolve but the basic concept works, Instead of populating all the tables with repetitive data, I simple populate the sites with the data they can change then with a change to the main post query I select data from the template site table to populate the data that they can not control.

    You are right the chaos caused by putting all this data into every table is not very smart. I went one step further and built a custom menu in the template custom menu builder. The end user can not change the pages and can not change the menu.

    What I actually would like to see in new blog templates is a way to track the sites created under each template. A simple parent_template_blogs_id field in the wp_blogs table would be nice. This would make the external programming problems more manageable. Right now I am having to enter this directly into the db. For obvious reasons, I do not want to make any changes to new blog template.

  • Ignacio

    Hi @Hatchman.

    I'm afraid that New Blog Templates has not that purpose. Though I'm trying to think a way to change sites after they are created, Alexander gave us a good definition of what NBT is:

    The responsibility of New Blog Templates is simple: to provision initial content

    That's all. If you'd like to change the plugin behaviour you'll need some custom coding because you're asking about something very specific.

    And about adding a new column to wp_blogs table. That's absolutely not possible. Ok, it is, but that's a WordPress native table and we should let that table as it is. Future updates could break everything.

    Regards.
    Ignacio.

  • Ignacio

    Hi @Hatchman.

    I'm afraid not, at least not for the moment, blogs already created cannot be changed after that.

    About the table: Yes, there is a table for templates in the recent version of the plugin but what you're asking about is a redesign of the plugin and right now we don't have plans to change it in that way. It needs to be rethinked and recoded again and that takes some time to.

    Regards.
    Ignacio.

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.