(Sorry for my english)

Next code will provide ability of simple style installation by just copying style folder (e.g. "blue_lagoon") into "styles" folder.

advanced_forum.module:

function advanced_forum_advforum_styles() {

  function dirlist($directory)
  {
    $dir_item_list = scandir($directory);
    foreach($dir_item_list as $k => $dir_item)
      if( !is_dir($directory.$dir_item) || $dir_item == '.' || $dir_item == '..' )
        unset($dir_item_list[$k]);

    $dir_item_list = array_values($dir_item_list);
    return $dir_item_list;
  }

  $style_name_list = dirlist(drupal_get_path('module', 'advanced_forum').'/styles/');

  $items = array();
  foreach( $style_name_list as $style_name )
    $items[$style_name] = array('directory' => 'styles/'.$style_name);

  return $items;
}

Comments

michelle’s picture

Status: Needs review » Postponed

Thanks, but I definitely don't want to be encouraging people to add styles to the advanced forum directory. That's a maintainance nightmare. I'll hold onto this code, though, because I've been thinking about making a simpler system in 2.x perhaps with a designated directory or something and this could come in handy.

Michelle

michelle’s picture

Version: 6.x-1.0-rc3 » 6.x-2.x-dev
Status: Postponed » Active
Passer’s picture

I dont agree with that!

Running different themes at once and holding the advanced forum themes in sync that is a maintance nightmare.

1) Why not holding all the forum themes in a single folder?
2) Why not putting them alltogether into one styles dir?
3) why not scanning this single subdir for all current themes (like suggested in threadstart)?

Are there any reasons?

Best Regards
Passer

tjodolv’s picture

I think what Michelle meant was that if users are encouraged to add their own styles to the advanced_forum directory inside the modules directory, most people would have forgotten that when they update their module some time in the future. Then, if you simply overwrite the entire advanced_forum folder, all your custom styles are lost and your forum look will "break". This will be very frustrating to a lot of users.

You could modify this code to search the current (or all) theme folders for advanced_forum styles though..?

Great work Michelle!

liquixis’s picture

(sorry for my english)

if you simply overwrite the entire advanced_forum folder, all your custom styles are lost and your forum look will "break"

Not, they are not lost. They will be lost only in case of whole "advanced_forum" folder deleting and then coping a new one.

I think that if someone create their own style, he must make a local backup of this style and store it locally for this or other cases. I think that is not too difficult...

Passer’s picture

"Not, they are not lost. They will be lost only in case of whole "advanced_forum" folder deleting and then coping a new one."

I agree with that.

If someone modifies the "naked"-theme, he is free to rename the folder to "naked2" (or something like that).

It is much more frustrating to copy a modified template to all theme folders (if users use custom themes).

michelle’s picture

Not, they are not lost. They will be lost only in case of whole "advanced_forum" folder deleting and then coping a new one.

Considering this is exactly what you are supposed to do every time you update the module, that would be every time.

I can't imagine that many people have completely different AF styles for multiple themes on one site. The vast majority of people are going to be running one theme and even of those running more than one theme can probably get away with just some style changes. So this really isn't that difficult.

Even so, simplifying it is on the agenda. If not in 2.x then in 3.x for sure.

Michelle

michelle’s picture

Also:

It is much more frustrating to copy a modified template to all theme folders (if users use custom themes).

Most people don't need to do this. Unless each theme has a different style, you just make a new style and use that. The current system is extremely flexible and fits the needs of 99% of the users.

These are the issues that need to be addressed:

1) If you want to use a different style for each theme, you need to copy the style changes to each theme. As I said, this use case is extremely rare, and it might not be changed if it proves too unwieldy to select a style per theme.

2) There is no way to allow users to select which style to use. This one might not be hard to do and is under consideration.

3) You need a module to create a completely new style outside of all themes. This is the one that will be fixed for sure because many people find making a module intimidating. My plan is to set a directory inside of the /themes directory at the same level as the themes to hold custom styles. This will be auto scanned so styles can simply be dropped in.

Michelle

Passer’s picture

"My plan is to set a directory inside of the /themes directory at the same level as the themes to hold custom styles. This will be auto scanned so styles can simply be dropped in."

This is a good idea.

What about this folder being in the files folder?

I am watching many modules preparing dirs there.

It is a bit nasty from modules to generate unrequested dirs, but a "standard" folder for all modules to store stuff, might be like
"files/modules/"

I am a friend of the idea that everything which is in the "sites/all/* directory hast to be unchangedstuff (directly downloaded).
Custom made changes all have to be stored in (a subfolder of) the "files" directory.
(easy backup)

michelle’s picture

Well, you may like that idea but that isn't the norm with Drupal. AF styles are very closely tied with themes so the most logical place to put them would be the themes directory. This isn't set in stone, yet, as I haven't coded it but is most likely what I'm going to do.

Michelle

michelle’s picture

Status: Active » Closed (duplicate)

Accidentally duped myself so merging into #497474: Allow per theme / per user styles

Michelle