Comments

James Andres’s picture

Status: Active » Needs review

Hi, I needed subsites module on a recent d7 project so I upgraded it. Find it here https://github.com/jamesandres/subsites.

Davy Van Den Bremt could you take a look and perhaps make a 7.x branch on Drupal.org based on the GitHub work? :-)

webankit’s picture

+1

WadeTheFade’s picture

Yes Please! My clients are in need of this too.

chaosmind’s picture

Ooh! Ooh! +1!!

rolandk’s picture

+1

clashar’s picture

+1

James Andres’s picture

Status: Needs review » Fixed

The 7.x-1.x has just been committed, a beta release to come shortly. Stay tuned :-)

dannymontalvo’s picture

+1

clashar’s picture

Status: Fixed » Active

I see no 7.x-1.x releases

philipz’s picture

+1
James was talking about GitHub release.
I was just thinking about going back Drupal 6 before I found this thread :) How's the beta release going ?

James Andres’s picture

Quick update, I've requested Davy make a 7.x-1.x release but am still waiting to hear back from him. I have commit access but can't create releases. I'll update here when I know more, sorry guys :-/. For now go ahead and use the 7.x-1.x branch from Git.

Also, there is a ticket open to upgrade the subsites_access project. I don't have the time to look into that one, anyone else care to give it a shot? I think the code in Git is nearly there (Coder Upgrade did a good job overall), just needs the final tweaks.

davyvdb’s picture

Status: Active » Fixed

I've created a dev release. Once, that has been tested and subsites_access is ported, we can move to an alpha/beta release.

rolandk’s picture

great news!

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

awm’s picture

sub

hbblogger’s picture

Version: 6.x-1.x-dev » 7.x-1.x-dev
Category: feature » bug

Hi James and Davy,

I am very interested in using your module. I have not used drupal 6, so I keep seeing these brilliant modules only available in DR7. I tried downloading James' version from his Git site, but there seem to be quite a few problems still (eg - I get an error when I try to attach a node and a I get a lot of errors if I try to activate the 'subsite access control' and then re-build permissions.) So, unfortunately I haven't been able to put any sort of site together.

Davy, you mentioned that you have a beta version, but there doesn't seem to be any mention of this anywhere on the Drupal site?

I would be happy to assist where I can with either testing or documentation. Unfortunately I'm not a proficient programmer!

Rgds Paul

James Andres’s picture

Hi houtbayblogger,

There is currently a Drupal 7.x dev version of subsites available from the project page (http://drupal.org/projects/subsites). Scroll all the way to the bottom and click on "View all releases". There is currently no officially sanctioned D7 release yet, that's why it isn't available on the main project page.

The version on github is completely obsolete, I'll remove it.

Thanks,

James

hbblogger’s picture

Hi James, Thanks very much for responding. I have downloaded and installed the version that you mentioned (7.x-1.x-dev).

The link in your site referring to documentation is broken, so I had to soldier on alone!

Initially I tried it on the site that I was working on (which has a number of other modules already installed) and I couldn't get past 'Rebuilding content access permissions' (got a page of Ajax 500 errors - mostly referring to place holders. I tried disabling some of the modules but no luck, so I did a clean install of Drupal (actually drupal 7.9) and the installation went fine.

I set up a sub-site using the structure/subsite menu. I then tried to set up a page (just used basic page as a node). I got access control errors, and realized I needed to set up permissions. Still got errors, so I disabled the subsites access control module - no further errors. Set up two test pages, both linked to subsites. Went to structure/subsites and tried to set up a menu. Got an error:

The requested page "/dr7.9/admin/structure/menu/manage/subsite-2-marlinspike?render=overlay" could not be found.

Not too sure what to do now. Is there something else that I should have set?

Possibly my approach is wrong? Are there any tutorials out there to help set up a basic sub-site and to link this to my main site?

I'd be happy to send you any errors that I encountered if it would help you in your development.

Cheers

Paul

hbblogger’s picture

Hi James, Thanks very much for responding. I have downloaded and installed the version that you mentioned (7.x-1.x-dev).

The link in your site referring to documentation is broken, so I had to soldier on alone!

Initially I tried it on the site that I was working on (which has a number of other modules already installed) and I couldn't get past 'Rebuilding content access permissions' (got a page of Ajax 500 errors - mostly referring to place holders. I tried disabling some of the modules but no luck, so I did a clean install of Drupal (actually drupal 7.9) and the installation went fine.

I set up a sub-site using the structure/subsite menu. I then tried to set up a page (just used basic page as a node). I got access control errors, and realized I needed to set up permissions. Still got errors, so I disabled the subsites access control module - no further errors. Set up two test pages, both linked to subsites. Went to structure/subsites and tried to set up a menu. Got an error:

The requested page "/dr7.9/admin/structure/menu/manage/subsite-2-marlinspike?render=overlay" could not be found.

Not too sure what to do now. Is there something else that I should have set?

Possibly my approach is wrong? Are there any tutorials out there to help set up a basic sub-site and to link this to my main site?

I'd be happy to send you any errors that I encountered if it would help you in your development.

Cheers

Paul

James Andres’s picture

Hi houtbayblogger, it sounds like you are attempting to use the subsites_access module. This part of subsites hasn't been upgraded for D7 yet (so that module won't work). You can follow progress of that issue here: #1248022: SAC: D7 Upgrade. Of course, if you're interested in helping to upgrade subsites_access that would be awesome too!

Subsites module installed without subsites_access should be a fairly smooth install (and it should be working). If you tried installing subsites_access first, then uninstalled it, it's hard to say what sort of changes (or breakage) may have occurred to your database. It's best to restore from a backup and only install subsites (without subsites_access).

hbblogger’s picture

Hi Andres, I'd love to help out but unfortunately I have not graduated to writing code. I've set up a clean installation and will re-try subsites with the subsites_access module removed.

hbblogger’s picture

OK, I have it up and running (again!) with similar bugs.

1. Try to open a new block and get the following error:

Notice: Undefined variable: form_id in subsites_form_block_add_block_form_alter() (line 47 of C:\wamp\www\dr2-7.9\sites\all\modules\subsites\subsites.blockvis.inc).
Notice: Undefined index: page_vis_settings in subsites_form_alter_block_visibility() (line 61 of C:\wamp\www\dr2-7.9\sites\all\modules\subsites\subsites.blockvis.inc).
Notice: Undefined offset: 1 in subsites_parse_block_visibility() (line 37 of C:\wamp\www\dr2-7.9\sites\all\modules\subsites\subsites.blockvis.inc).

2. Try to connect to an existing node/page

Deprecated function: Function eregi() is deprecated in subsites_content_nodes_form_submit() (line 252 of C:\wamp\www\dr2-7.9\sites\all\modules\subsites\subsites.admin.inc).
Node not added. Not a valid node.

but when I go to the node and choose the site to attach to, it gets added.

The errors are the same as for the previous installation where I had only disabled (not removed) the subsite_access module.

Neither of these seem to be show stoppers. If I come across any others, I'll let you know.

tmedlen’s picture

houtbayblogger, this is what I did to suppress the errors, not having the eregi() issue though; edited subsites.blockvis.inc

line 36 changed
if (count($matches > 1)) to if (count($matches) > 1)

then in function subsites_form_alter_block_visibility changed the $pages variable

$pages = $form['page_vis_settings']['pages']['#default_value'];
changed to
$pages = $form['visibility']['path']['pages']['#default_value'];

for the form_id error I added $form_id = $form['form_id']['#value']; inside functions subsites_form_block_add_block_form_alter & subsites_form_block_admin_configure_alter

function subsites_form_block_add_block_form_alter(&$form, $form_state) {
  $form_id = $form['form_id']['#value'];
  subsites_form_alter_block_visibility($form, $form_state, $form_id);
}
function subsites_form_block_admin_configure_alter(&$form, $form_state) {
  $form_id = $form['form_id']['#value'];
  subsites_form_alter_block_visibility($form, $form_state, $form_id);
}

- hope this helps

hbblogger’s picture

Many Thanks tmedlen, That has solved problem 1 and the second one is easy to work around. Rgds Paul

strykaizer’s picture

Status: Closed (fixed) » Needs review
StatusFileSize
new1.65 KB

Attached you'll find a patch containing tmedlen's code, fixxing issue 1 in post #22

rta’s picture

//404 not found for this link
:(

James Andres’s picture

@rta, the official Subsites d7 branch is on drupal.org. It is not on github any longer.

yareckon’s picture

I've patched the problems with the node add process (repairing the autocomplete callback to return nid, and replacing the deprecated eregi function with preg_match).

Attached are two patches, one that contains only my changes without the patch from 25, and one that for convenience contains the block system changes from #25 in addition.

yareckon’s picture

Sorry, this file is the one without

yareckon’s picture

StatusFileSize
new1.32 KB
new524 bytes

Here is an addtional patch that fixes the link from the subsite screen to the subsite menu edit page.

I've also rolled a cumulative patch containing all of the patches in the thread.

yareckon’s picture

There is also Alan. D. 's code over in the other thread #1359942: D7 port , that makes subsites into entities. I am interested in fusing the two approaches.

The existing subsites module has the ability to use path based selection and better block handling, but in the other module, subsites as entities are fieldable, which one can use to store a lot of extendable data about the subsite with no extra work (logo fields, About page, colorpicker, views integrations references etc..)

I would be interested in making the core subsite into an entitiy that could be fieldable, but keeping the idea of a subsite as a container that could be active on paths and other nodes rather than just on items that are in a particular menu like in Alan D.'s module.

James Andres, are you interested in this approach at all? I've contacted Alan D about whether he could work on it.

francescoq’s picture

Hi, i'm using subsite for D7 in a work, when i try to show the subsite name between the fields in a view i've got this error

An AJAX HTTP error occurred.
HTTP Result Code: 200
Debugging information follows.
Path: /admin/structure/views/view/calendar/preview/page_5/ajax
StatusText: OK
ResponseText: 
( ! ) SCREAM: Error suppression ignored for
( ! ) Fatal error: Call to undefined function db_placeholders() in X:\...\webroot\sites\all\modules\subsites\views\views_handler_field_node_subsites.inc on line 28
Call Stack
#TimeMemoryFunctionLocation
10.0002816840{main}(  )..\index.php:0
21.439249721968menu_execute_active_handler(  )..\index.php:21
31.450751867232call_user_func_array
(  )..\menu.inc:517
41.450751867632views_ui_build_preview(  )..\menu.inc:517
51.458852406936views_ui_preview(  )..\admin.inc:954
61.572962232552view->preview(  )..\admin.inc:176
71.575962442144views_plugin_display->preview(  )..\view.inc:1360
81.575962442192view->render(  )..\views_plugin_display.inc:2673
91.625164147056views_handler_field_node_subsites->pre_render(  )..\view.inc:1231

i can't understand what happens.. at the moment i'm using taxonomy (with same name of my 2 subsites) on the desired content type to bypass the problem, but it's not a quite a good way to do it :P

from a quick search i can see that maybe db_placeholders() is a D6 only function... but i don't understand very well all those things, i'm sorry!

Thank you!

alan d.’s picture

I've contacted Alan D. about whether he could work on it.

Sadly no time to push any energy into this, but having fields is very useful. Definitely recommend adding these :)

The function db_placeholders() is gone, replace with updated db classes and do something like this instead:

db_select('target_table', 't')->condition('t.target_field', array('a','b','c',...));
db_select('target_table', 't')->condition('t.target_field', array('a','b','c',...), 'NOT IN');

francescoq’s picture

Hi, i tried to replace the db_placeholder() function.
I'm a beginner in these thing so i don't know if everything is fine.. (and i don't know yet how submit a patch even if everything is ok :) )
So..
i replaced the old lines

  $placeholders = db_placeholders($nids, 'int');
  $sql = "SELECT n.nid, s.sid, s.name FROM {subsites} s INNER JOIN {subsites_node} n ON s.sid = n.sid WHERE n.nid ORDER BY s.name";
  $result = db_query($sql, $nids);

with these

  $query = db_select('subsites', 's');
  $query -> innerJoin('subsites_node','n','s.sid = n.sid');
  $query -> fields('s', array('sid', 'name'))
    -> fields('n', array('nid'))
    -> condition('n.nid', $nids, 'IN');
  $result = $query->execute();

the result of the query is

SELECT s.sid AS sid, s.name AS name, n.nid AS nid FROM {subsites} s INNER JOIN {subsites_node} n ON s.sid = n.sid WHERE (n.nid IN (:db_condition_placeholder_0, :db_condition_placeholder_1))

everything seems ok to me, it works in my case.

Hope it can be useful to someone!

francescoq’s picture

I've created the patch, it's my first one.. so i hope everything is ok!

EDit: ok.. it doesn't seems to work the attachment.. i try to find out why.. sorry

francescoq’s picture

StatusFileSize
new1.09 KB

Here's the patch to show the subsite field in views :)

francescoq’s picture

I took a look at Subsite Access Control, and submitted a patch that worked for what i can see (i'm not using it, so maybe i haven't tested in all conditions).
http://drupal.org/node/1248022

francescoq’s picture

StatusFileSize
new693 bytes

I found that if the view have no result a notice is given, this should fix the problem

m4olivei’s picture

Hello!

First off, great idea for a module. We've been implementing variations on the same thing for a couple different projects. I had in mind to redo our internal "subsites" module, when I found this module, which incorporates a lot of the same ideas I had and more. So instead, I've patched the D7 version of this module big time. The patch is attached. I've incorporated all patches in this thread, plus a few more bug fixes and feature adds:

  • Fixed bug where a cache clear was required before being able to edit the menu that was auto-created.
  • Fixed bug where the block visibility settings rendered outside the vertical tabs.
  • Refactored block visibility code to follow D7 conventions and to work for D7 when rendering.
  • Cleanup code style here and there, add documentation.
  • Remove old D6 menu_link creation
  • Add a Delete button to the site information edit form as per convention.
  • Refactor _subsites_add() and _subsites_edit() into _subsites_save().
  • Add the ability to select from all menus which menus should activate the subsite.
  • Remove auto-delete of created menu on subsite delete, nothing say's that menu can't be used elsewhere, so it would be sad if it were deleted unexpectedly.
  • Testing
  • Update hooks to bring the schema up to date
  • Add the ability to override the site name, slogan and front page for a subsite

Still a few things I'd like to do:

  • Review views and context integration, ensure that they are working correctly.
  • Allow override of logo

Please try it out and let me know! The patch is against the latest in the 7.x-1.x branch.

Thanks,
Matt

m4olivei’s picture

New inclusive patch that includes a bug fix to the views integration, as well as a couple extra handler definitions. Also includes JS that updates the vertical tab summary on the node edit form (which may have got lost). Finally, includes the ability to override the logo per subsite from the Look and Feel tab.

Let me know what you think.

francescoq’s picture

Hi! Great work!! i'm going to try it out in this weekend i think, i need this module for an extra-work site, so i haven't much time to work on it, thanks so much!

francescoq’s picture

Hi, I tried to apply the patch on my site, but after running updates it gives me a lot of notice: 321 of these:

Strict warning: Declaration of views_handler_field_node_subsites::pre_render() should be compatible with views_handler_field::pre_render(&$values) in require_once() (line 6 of 
C:\[...]\webroot\sites\all\modules\subsites\views\views_handler_field_node_subsites.inc).
Notice: Trying to get property of non-object in subsites_access_control_perm() (line 141 of 
C:\[...]\webroot\sites\all\modules\subsites\subsites_access_control\subsites_access_control.module).
Notice: Trying to get property of non-object in subsites_access_control_perm() (line 142 of 
C:\[...]\webroot\sites\all\modules\subsites\subsites_access_control\subsites_access_control.module).

And when i view any page of the site this is the error.

( ! ) Fatal error: Cannot use object of type stdClass as array in 
C:\[...]\webroot\sites\all\modules\subsites\plugins\subsites_context_condition_subsites.inc on line 68
Call Stack
#	Time	Memory	Function	Location
1	0.0015	142296	{main}( )	..\index.php:0
2	0.0195	442632	drupal_bootstrap( )	..\index.php:20
3	1.4795	2884088	_drupal_bootstrap_full( )	..\bootstrap.inc:2198
4	2.8849	16755808	menu_set_custom_theme( )	..\common.inc:5117
5	2.8849	16755856	menu_get_custom_theme( )	..\menu.inc:1769
6	2.8850	16756216	module_invoke_all( )	..\menu.inc:1747
7	2.8870	16757384	call_user_func_array ( )	..\module.inc:857
8	2.8870	16757480	subsites_custom_theme( )	..\module.inc:857
9	8.6427	34501088	subsites_context_condition_subsites->execute( )	..\subsites.module:189

Maybe I can't use the patch in a project with subsite already installed?

Now i dig in it to understand something!

francescoq’s picture

Hi, i'm trying to use it in another project. Starting from zero and applying #40 works for me... But I've a problem in context plugin: if i select a condition where i want a subsite there's no problem, but if i check -Main site- option at execution time (function execute($subsite) ) $subsite is an object, not an array.. so it doesent' work.
At the moment i added

      if (is_object($subsite)) {
        $subsite = (array) $subsite;
      }

only to use it.. but i can't understand why sometimes $subsite is an array and sometime an object

francescoq’s picture

ok... sorry i haven't seen before... here's the catch

  if ($sid) {
    // Fetch subsite object
    $subsite = subsites_get($sid);

    // Add css file
    drupal_add_css(subsites_get_css_path($sid));

    // Switch to custom theme, this will only take effect if theme is active
    // to prohibit a destroyed site
    $custom_theme = $subsite['theme'];
  }
  else {
    $subsite = (object) array('sid' => -1, 'name' => t('Main site'));
  }

why?! i can't see a valid reason to make this difference... i see it as a risk

sivapattabhiram’s picture

Issue summary: View changes
StatusFileSize
new1.8 KB

Hi! I integrated the patch by m4olivei (#40) and could get the basic functionality working without any problems. Some of the issues I faced are:

a) The template files are not recognized by the subsite. I have modified the function subsites_preprocess_page() to use D7 'theme_hook_suggestions' variable. Have also renamed the template suggestions to page__subsites__ which is in line with the D7 convention (the existing page-subsites- suggestion was not working).
As a consequence, the template files need to be named as page--subsites--{subsite-id} or
page--subsites--{subsite-slug-name}.tpl.php

b) The menu blocks were not working. I have modified the subsites_get() function to query the menu name from db and subsites_block_view() function to use drupal_render() to render the menu tree.

Please find attached the patch with these fixes. You have to apply patch #40 on 7.x-1.x branch before this.

  • gisle committed 9124e2a on 7.x-1.x authored by m4olivei
    Issue #800880 by yareckon, FrancescoQ, m4olivei, StryKaizer,...
gisle’s picture

Title: Subsites for drupal 7 » Subsites: Upgrade to drupal 7 of main module
Component: Miscellaneous » Code
Assigned: Unassigned » gisle
Category: Bug report » Task

Patch in #40 has now been applied to the repo and pushed to 7.x-1.x-dev.

I'm, still reviewing comments #42-45 and the patch in #45. Any help with reviewing will be much appreciated.

chunty’s picture

For anyone having problems rebuilding permissions due subsites access control. I found that the problem seemed to be down to subsites_access_control_node_access_records using boolean values in the array.

If you change all these to use respective integers then it seems to work ok:

I end up with the following function:

<?php
function subsites_access_control_node_access_records($node) {
  $grants = array();

  $sid = $node->subsite ? $node->subsite : 0;

  $grants[] = array(
    'realm' => "subsites_view_{$node->type}",
    'gid' => $sid,
    'grant_view' => 1,
    'grant_update' => 0,
    'grant_delete' => 0,
  );

  $grants[] = array(
    'realm' => "subsites_update_{$node->type}",
    'gid' => $sid,
    'grant_view' => 1,
    'grant_update' => 0,
    'grant_delete' => 0,
  );

  $grants[] = array(
    'realm' => "subsites_delete_{$node->type}",
    'gid' => $sid,
    'grant_view' => 1,
    'grant_update' => 0,
    'grant_delete' => 1,
  );

  $grants[] = array(
    'realm' => "subsites_view_own_{$node->type}_{$sid}",
    'gid' => $node->uid,
    'grant_view' => 1,
    'grant_update' => 0,
    'grant_delete' => 0,
  );

  $grants[] = array(
    'realm' => "subsites_update_own_{$node->type}_{$sid}",
    'gid' => $node->uid,
    'grant_view' => 1,
    'grant_update' => 1,
    'grant_delete' => 0,
  );

  $grants[] = array(
    'realm' => "subsites_delete_own_{$node->type}_{$sid}",
    'gid' => $node->uid,
    'grant_view' => 1,
    'grant_update' => 0,
    'grant_delete' => 1,
  );

  return $grants;
}
?>
gisle’s picture

Assigned: gisle » Unassigned

Unassigning.

andrey.troeglazov’s picture

Hello,
I`m working on it, any help will be appreciated. Thanks!

andrey.troeglazov’s picture

Assigned: Unassigned » andrey.troeglazov

andrey.troeglazov’s picture

Assigned: andrey.troeglazov » Unassigned
Status: Needs review » Fixed

Applied patch from #45 and used changes from #48 with some changes.
Thanks to all, commited to dev branch.
Checked general functionality, for me its ok, but there is some notices.
Closing the issue, if someone wants to fix any other issues please open new ticket.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.