To allow theme to supply additional styles on top of default styles provided by superfish.module. Theme can supply additional superfish styles by defining a css/superfish/superfish.inc and related css files. More than one styles can be provided by a theme.

Instead of the need to keep updating superfsh.module to include new styles, new predefined styles can be easily added by configuring libraries/superfish.inc

The code is easily extendable to support additional configuration and even superfish style from module (but couldn't think of a reasonable use case for that).

Comments

ckng’s picture

Status: Active » Needs review
StatusFileSize
new1.22 KB
new2.75 KB

Patch attached.

superfish.inc_.txt is to be renamed superfish.inc and put inside libraries/superfish/ folder.

ckng’s picture

From within a theme, says 'foo'
- add foo/superfish/superfish.inc
- add your superfish style, foo/superfish/foo.css

Example of foo/superfish/superfish.inc, see superfish.inc_.txt in #1 for multiple styles example

<?php
$path = drupal_get_path('theme', 'foo');
$info = array(
  // Theme superfish styles.
  'styles' => array(
    'foo' => t('Foo style'),
  ),
  'data' => array(
    'foo' => array(
      'file' => $path . '/css/superfish/foo.css',
    ),
  ),
);
ckng’s picture

Potential future extensions of the configuration could cover a particular style's
- predefined superfish settings
- forced settings of the superfish
- superfish types support (horizontal, navbar, etc)
- different css file for desktop/mobile (touch) style
- ...
- let your imagination run wild =)

mehrpadin’s picture

Hey CK,

Thanks for this, I was thinking of rather a function to override through template.php; also "Superfish type support..." was available since v1! and "desktop\mobile..." is doable through your CSS files (http://w3schools.com/css/css_mediatypes.asp)

ckng’s picture

I think you misunderstood #3, I'm awared of the sf type support and media queries. What I'm referring to are possibilities for a theme supplied Superfish styles to override superfish.module configuration with its own predefined setting or notify superfish.module the features it supports.

For example, a theme foo could includes a superfish style without making changes to superfish module or write additional code (think pure themer). This is covered by the current patch.

In the future, as superfish.module adding new possible theming like the new megamenu, this style could tell superfish.module that it only support says horizontal superfish menu and not megamenu because it is not themed for that. Anyway, these can be put aside ATM.

ckng’s picture

StatusFileSize
new3.75 KB

- Fixed a bug when a theme is changed/removed, the style is longer available.

Don't forget superfish.inc_.txt in #1
superfish.inc_.txt is to be renamed superfish.inc and put inside libraries/superfish/ folder.

manos_ws’s picture

This is a very useful feature.
To make more clear how ckng's implementation works here it is in 6 steps:

1. Get the dev version http://drupal.org/node/1103384 (I tested it with Last updated: March 28, 2011)

2. Get the patch from #6 and apply it

3. Get the superfish.inc_.txt from #1 , put it in sites/all/libraries/superfish and rename it to superfish.inc

4. Create a folder in your theme css folder called superfish

5. Create a file called superfish.inc inside that folder

6. Add the following code remembering to change your drupal's theme name and your superfish themes name

<?php
$path = drupal_get_path('theme', 'YOUR_DRUPAL_THEME_NAME');
$info = array(
  // Theme superfish styles.
  'styles' => array(
    'YOUR_SUPERFISH_THEME_NAME' => t('YOUR_SUPERFISH_THEME_NAME'),
  ),
  'data' => array(
    'your_superfish_theme_name' => array(
      'file' => $path . '/css/superfish/YOUR_SUPERFISH_THEME_NAME.css',
    ),
  ),
);

FURTHER IMPLEMENTATION.

My suggestion for adapting the patch from #6 is:

Dismiss the file from step 3 (sites/all/libraries/superfish/superfish.inc)
In the module's code to leave intact the other default styles (#options in the module's form).
The you are able to update the superfish library easily

My time is limited right now but I may come back for a patch.

franzkewd’s picture

Subscribe

ckng’s picture

@Mehrpadin
Do you have plan to get this in?
If not I need to think of alternative that will work for me. This issue has been idling far too long.

mehrpadin’s picture

Ni hao,

This is already added, in a different way though, it'll be available within a few days with the new version.

franzkewd’s picture

re: #10. Thanks Mehr...

ckng’s picture

Why not push the new code to git so we can test it out?

mehrpadin’s picture

Status: Needs review » Fixed

The requested featured added as of v1.9-beta3 :)

ckng’s picture

Status: Fixed » Active

From what I can tell from the code, v1.9-beta3 only scans css filename in the libraries folder.

What about support for theme provided style?
Or "..function to override through template.php.." as you mentioned in #4?

Thanks.

Note: Something wrong with the '7.x-1.9-beta3' tag in the D7 dev branch, it is not the latest in 7.x-1.x, have to manually checkout based on tag. As can be seen from http://drupalcode.org/project/superfish.git/shortlog/refs/heads/7.x-1.x

tanitani’s picture

First off - Thank you for the work y'all!

This is not so much a question as it is a comment.

As I am working hard to convert a site to Drupal and therefore on themeing a couple of SF menus exactly as they were on the site (and being a noob with Drupal and CSS), I could not help but wonder about the efficiency of Drupal's approach to CSS.
SF is being styled from at least 3 or four SF specific files in my case (using the Mayo theme) and maybe another 2 from the Drupal side. I find that rather confusing and cannot imagine that it is very effective...

However, Mehrpadin, you provided a way (maybe inadvertently), to inject my own CSS file into all of the pages , which I could not find a good way to do otherwise, as the some SF menu appears on EVERY page, therefore the CSS that the SF style dropdown uses appears on every page and it gets optimized into the monster css as well when you do optimize the site. See for the method description in Additional styles.
(I know that there is also a specific field in the block definition for a css file and that may have worked as well, but I felt that this method was "higher" in the cascade...)

In any case thanks people, you've got one fan here.

Gábor

ckng’s picture

@Mehrpadin,
If you prefer not to support theme supplied styles (the highest use cases I encounter), for whatever reasons, then at least provide a hook or something for us to add to the style option.

The patch in #1 provided a clean option for that, if you do not like it, please tell me how you like to be done so I can contribute. I'm seriously in need of this feature, I'm already considering to fork this project.

Sorry for the harsh comment.
I'll just give user additional step to do, by asking them to copy the style to the libraries folder manually.

But having this issue #1367086: Undefined index in superfish_styles()

mehrpadin’s picture

Gabor,
Take a look at these:
http://drupal.org/node/171205#stylesheets
http://api.drupal.org/api/drupal/includes--common.inc/function/drupal_ad...
http://api.drupal.org/api/drupal/includes--common.inc/function/drupal_ad...

CK Ng,
It's not harsh at all, I was just busy and I still am as a matter of fact, well I know this is very needed but when I started v1.9 development I searched the API and elsewhere for a standard way and it seems like Drupal does not have any as of yet, therefore I decided to do the rest of the things until I find something, I know I can add a hook or something like that but what I expect is a solution for all the modules and for all the blocks, something like "Import\Export" for blocks settings, like a file that the end-user uploads and gets all or some of the blocks configured according to and blabla.

ckng’s picture

@Mehrpadin
Just curious, what is the problem with the approach I proposed in the patch? It is cleaner and don't need to mess with "import/export", upload, configuration, etc.

mehrpadin’s picture

Status: Active » Closed (fixed)

Apologies for missing this; cannot recall the exact reason, but my approach is quite similar to yours anyway; will close this, feel free to reopen if necessary.