WordPress.org

Ready to get started?Download WordPress

Forums

Static frontpages (19 posts)

  1. ferdri3
    Member
    Posted 2 years ago #

    Hello everyone,

    I just reinstalled the latest WP and activated Multisite (sub-domain) after failing at something non-important to this issue lol

    I want the static page I made to show up as default in all new registrated (and if possible all old ones too) instead of the blog layout.

    A user does get the option to change it to a static page, however, the one I created does NOT show in their list when trying to set this (it does show in my own main website optionlist).

    Anyone can help me with this?
    Thanks in advance!

    PS. I understand they can make a new Page and select that .php file on the right. But I want to disable the option to make new Pages.

  2. ferdri3
    Member
    Posted 2 years ago #

    (unable to edit previous post)

    I read
    http://wordpress.org/support/topic/add-multiple-pages-on-wp-multisite-by-default?replies=13
    just now and I understand how I can make static pages for each site.. now I need to know how to make 1 Page the default page on all sites.

  3. You'd want to get a plugin like http://wordpress.org/extend/plugins/wpmu-new-blog-defaults/ for that one.

  4. ferdri3
    Member
    Posted 2 years ago #

    Hey Ipstenu,

    if you follow the link I provided, you see the same link somewhere there as what you just gave me. I understand that plugin just give the site-admins options (or removes them).

    To get a better view of what Im trying to create:
    When a new site-admin is registrated (which they can without permission) they get a website like "mysite.example.com". If they visit that URL they get to see "Home" which displays a blog with 1 example post in it and an "About Me" Page.

    I removed some code in wp-admin/includes/upgrade.php to prevent the blog from being made by default. So now they only get the "About Me" Page after registrating. I also Editted some code in the same file which gives them another Page instead of "About Me".

    Till now it all worked out. But I dont only want a replacement for "About Me", I want to give that replacement a template (which can normally be set on the right) I created (yes the template works).

    So what Im guessing is that I need to change this code below to assign a template to it:

    // Second Page
    	$second_page = sprintf( __( "" ), admin_url() );
    	if ( is_multisite() )
    		$second_page = get_site_option( 'second_page', $second_page );
    	$second_post_guid = get_option('home') . '/?page_id=3';
    	$wpdb->insert( $wpdb->posts, array(
    								'post_author' => $user_id,
    								'post_date' => $now,
    								'post_date_gmt' => $now_gmt,
    								'post_content' => $second_page,
    								'post_excerpt' => '',
    								'post_title' => __( 'Home' ), // Shows in Menu bar
    								/* translators: Default page slug */
    								'post_name' => __( 'front-page' ), // URL -> example.com/'xxx'/
    								'post_modified' => $now,
    								'post_modified_gmt' => $now_gmt,
    								'guid' => $second_post_guid,
    								'post_type' => 'page',
    								'to_ping' => '',
    								'pinged' => '',
    								'post_content_filtered' => ''
    								));
    	$wpdb->insert( $wpdb->postmeta, array( 'post_id' => 3, 'meta_key' => '_wp_page_template', 'meta_value' => 'homepage.php' ) );

    The template name is "homepage.php" and I uploaded it to example.com/wp-content/themes/mytheme

    In the code above I tryed to add it on the bottom (without luck)
    Normally its:
    'meta_value' => 'default' ) );

  5. I removed some code in wp-admin/includes/upgrade.php to prevent the blog from being made by default.

    NO! DO NOT DO THAT EVER! Don't ever ever ever edit core. I'm not kidding.

    The whole point of using the plugin is to avoid editing core. Which, by the way, I categorically refuse to help anyone with on the forums.

    In the very basic /wp-admin/network/settings.php page, you can customize what your initial pages and posts should be.

    There's an older plugin, http://wordpress.org/extend/plugins/default-blog-options/, that may have the part you're looking for, but the basic rule here is this: Use a plugin to make WP do what you want, don't edit core.

    You wanna edit, you're on your own.

  6. ferdri3
    Member
    Posted 2 years ago #

    Im not planning on updating WP in the future, so I should be ok with editting the core, but I understand why you are against it.

    Ill give that plugin a try, hoping that multisite hasnt changed to much since 3.0.1

    Thanks for the help! If it doesnt work, Ill try adding this:

    <?php
     update_post_meta($id, "_wp_page_template", "new_template.php");
    ?>
  7. ferdri3
    Member
    Posted 2 years ago #

    plugin doesnt work :( doesnt show my pages/posts/tags/etc
    Code also doesnt work (unless I do it wrong lol)

  8. Im not planning on updating WP in the future, so I should be ok with editting the core, but I understand why you are against it.

    Now that's just stupid. Sorry, but you should ALWAYS upgrade WordPress when a new version comes out.

    The older plugin's not supported anymore (which is why I generally don't suggest it), but since you seem to understand how the basis of the code works, you should be able to spend some time rewriting it and making it work for what you need. Basically this: Spend your time learning to write a plugin vs editing core.

  9. ferdri3
    Member
    Posted 2 years ago #

    ok, still having the same problem.
    sort-of fixed the plugin, but it doesnt do what I need it to do.

    Here again what I try to get:

    Every new registrated site should automatically get a default static page WITH a template (normally you can add a template on the right side while creating or editting a page). This template is already created and working.

    The reason I want this, is that the page is needed, but also because I want to disable the option forsite-admins to create any other pages.

    If there is any other way than messing with the core, Ill take it.. but if not, Ill take it aswell.

    All help is welcome! Thanks in advance!

    PS. normal page template is "page.php".. how about replacing that with my own code? Or will that mess up a contact form page for example?

  10. I want to disable the option forsite-admins to create any other pages.

    ANY pages? Hide the menu.

    http://wordpress.org/extend/plugins/admin-menu-editor/

    PS. normal page template is "page.php".. how about replacing that with my own code? Or will that mess up a contact form page for example?

    That's something you'd do in a theme, really. Change the theme template and off you go.

  11. ferdri3
    Member
    Posted 2 years ago #

    Thanks Ipstenu!

    Both worked.. now the last thing I need is to automatically create a page.
    I was hoping this could be done in functions.php - Something like this:

    [Code moderated as per the Forum Rules. The maximum number of lines of code that you can post in these forums is ten lines. Please use the pastebin]

    However, it doesnt work because of a "hook" but I dont know which one or how to edit this code.
    Also I would like to hide or delete the creation of a blogpost (which is visible everytime a new site is made)

  12. The more you tell us about what you're limiting people on their site, the more I wonder what the heck you're doing (and yes, it usually does matter).

    If people can't make new posts or pages on a site, what CAN they do, and why are you mucking around with giving them these sites?

  13. ferdri3
    Member
    Posted 2 years ago #

    My intention is to let people create their own 1 page site.
    (yoursite1.domainname.com for example)

    On this 1 page they get are widget area's (now by selecting a template).
    But since they can add whatever to a page, I want to restrict access to the page-menu by hiding it. However, if I hide that menu, people cant create that 1 page right? And that "Example Page" they do get has a title + text in it AND it doesnt have the template selected (so the widget areas are not there).

    If it was the way I want it to be it would be like this:
    - Person makes a site.
    - Site automatically gives person a Page (not visible in the main-menu, since that is a sidewide menu).
    - Person fills in the widget area's with widgets (since the Page has a template)

    The person does not see an example-blog-post and a example-page, just the 1 (custom) page I created with widget area's.

  14. I think Multisite's the wrong way to do this. What you're doing is taking a car and making people use it like a unicycle instead. It CAN be done, but you're putting in a metric tonne of effort for it.

    I would use Custom Post Types and a Memebers plugin instead.

  15. ferdri3
    Member
    Posted 2 years ago #

    in that case there wont be sub-domains which is demanded.

    Im sure there is a way in functions.php for example to make a page by default. How else do the 2 example pages get created.

    The template isnt an issue anymore because I changed page.php so any new page should have the layout with widgets in them.

    I searched a little more and found this for functions.php:

    add_action('wpmu_new_blog', 'default_settings', 100, 2);
    function default_settings($blog_id, $user_id){
        switch_to_blog($blog_id);
    
        // setup your page here
    
        restore_current_blog();
    }

    and page setup should be something like this:

    $pages_to_create = array_diff($default_pages,$temp);
    foreach($pages_to_create as $new_page_title){ 
    
    // Create post object
    $my_post = array();
    $my_post['post_title'] = $new_page_title;
    $my_post['post_content'] = 'This is my '.$new_page_title.' page.';
    $my_post['post_status'] = 'publish'; $my_post['post_type'] = 'page';

    However, this goes a bit beyond my php knowledge and I have no clue how to get this work, IF it even works

  16. I don't often say this.

    WordPress is possibly the wrong tool for this job.

    Based on the requirements you provided (One page on a subdomain that can't be edited, added to, etc, save the 'widgets'), there's no good, easy, sustainable way to do this. I mean... You're just going to be miserable, and I'd say screw it and do this one manually. Make a manual subdomain, put one damned html file in, call it a day.

    The users can fill in a form to say 'I want this...' and it's a static page.

    If you use Multisite, you're totally crippling it and forcing yourself to rely on multiple tweaks and hacks. If you use anything else, you have a harder time with the subdomains. I mean, the only other subdomain method I know of off the top of my head is http://wordpress.org/extend/plugins/wordpress-subdomains/

  17. ferdri3
    Member
    Posted 2 years ago #

    I know the options I give dont really makes use of WP's full potential.

    The thing is that there are ideas for the future to make some options open again, hence the need of WP. Besides that, it needs to be low maintenance.
    So WP is actually the best option for this project. Everything is ready to go except for the page which needs to be created every time a new site is created. And as I said before, WP has this code somewhere because there are already pages created everytime a site gets made.

    Now I tryed to make the following code for functions.php but as I expected it doesnt work.. perhaps someone could help me with making this code work (debug it?)

    add_action('activate_blog','my_default_pages');
    
    function my_default_pages(){
        $default_pages = array('About','Home','My Store','My Address');
        $existing_pages = get_pages();
    
        foreach($existing_pages as $page){
            $temp[] = $page->post_title;
            }
    
        $pages_to_create = array_diff($default_pages,$temp);
    
        foreach($pages_to_create as $new_page_title){
    // Create post object
                $my_post = array();
                $my_post['post_title'] = $new_page_title;
                $my_post['post_content'] = 'This is my '.$new_page_title.' page.';
                $my_post['post_status'] = 'publish';
                $my_post['post_type'] = 'page';
    
                // Insert the post into the database
                $result = wp_insert_post( $my_post );
    
            }
            }

    I also tryed the hook: wp_head
    and the hook: wpmu_activate_blog

  18. Let's look at it from a different angle for a second...

    Are the USERS making these sites themselves or are you generating them?

    Because if you're making them, Blog Copier would be a fantastic idea here. Just make a 'sample' site, and use that to copy everything when you make a new site.

    http://wordpress.org/extend/plugins/blog-copier/

  19. ferdri3
    Member
    Posted 2 years ago #

    The users are making it themselves.. they go to the main website and register to create their own site and add content themselves. There should be nothing I should do..

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.