How do I use this module?

Ive just updated to the latest version and my rounded corners have stopped working. Ive read the documentation but im still confused.

It says something about 'copy this code snippet to your custom module'. Do I need to create a custom module or does this module include a place for the code? Im assuming there is no longer a UI?

Thanks

Comments

amitaibu’s picture

Status: Active » Fixed

> Do I need to create a custom module

Yes. And then you need to place the code inside a function. If you'd like to round corners to happen on every page you can place it in hook_init(). So, if your module's name is foo,then:

function foo_init() {
 // Place the code here.
}
mshepherd’s picture

I've got the same problem.
I've been using this module for a while. And now in order to carry on using it, I've got to write my own module?
There was a UI before. Where's that gone?
This seems like quite a regression to me...

Can I still download the old verison?

jdln’s picture

OK thanks. Do you know if the current version will have a UI like the last release at some point? At the moment ive gone back to using the 6.x-2.0 as the UI is so convenient.

mshepherd’s picture

I agree.

While I understand the attraction of opening up the module as an API, losing the UI is a big backward step in my opinion.

For now, I've gone back to 2.0.

amitaibu’s picture

You may still use the 2.x version if you are more comfortable with it, although - at least for me - the fact that 3.x is in code (i.e. exportable) is more important than a UI.

With that said, there could be a UI as a separate module (i.e. rounded_corners_ui), but I have no plans for it yet, unless someone would like to sponsor my work.

director87’s picture

I understand the work, but I understand the need for a UI.
If I can help out, I'll try to.

amitaibu’s picture

@director87,
Great, the idea is to add a menu item, that shows a form a user may add round corners, but not inside a textarea with freetext, but through selections restricted to the options provided by the API.

director87’s picture

@Amitaibu I'll give it a go and post my work here.

bennash’s picture

subscribing. I'm also a little frustrated with this upgrade path, but willing to help, after getting familiar with the new approach. Thanks for everyones work here.

jimmb’s picture

I updated Rounded Corners, and then needed the additional info. in this post! After reading it, I made a custom module using these instructions.

The code I previously had in the UI was:

$("#primary-menu.primary-menu.block a").corner("round 20px");

Following the "README" instructions, inside my menucorners.module" I put:

<?php
/**
   * Implementation of hook_init().
   *
   * Add round corners to the primary links.
   */
function menucorners_init() {
$commands = array();
$commands[] = array('selector => '.menucorners', 'corners' => 'round', 'width' => 20);
rounded_corners_add_corners($commands);
}
?>

However, after I enabling the module I get this message:
"Parse error: syntax error, unexpected T_CONSTANT_ENCAPSED_STRING, expecting ')' in /home/ddhfb/public_html/sites/all/modules/menucorners/menucorners.module on line 9"

Line 9 is:

$commands[] = array('selector => '.menucorners', 'corners' => 'round', 'width' => 20);

I'm not a PHP coder, so I'm not sure what needs to be changed. But I think I applied my settings correctly to the example code... Anyway, some help will be much appreciated!

Jim

amitaibu’s picture

I see the problem. The readme has a missing - ' after the word "width" and "selector".

The line should be:

= array();
$commands[] = array('selector' => '.menucorners', 'corners' => 'round', 'width' => 20);

I'll fix the README.

jimmb’s picture

Hi Amitaibu,

Thanks for the reply. I just made that change on line 9, and uploaded the custom module again. However, now I'm getting a new error:

"Fatal error: Call to undefined function rounded_corners_add_corners() in /home/ddhfb/public_html/sites/all/modules/menucorners/menucorners.module on line 10"

Line 10 is:

rounded_corners_add_corners($commands);

UPDATE:

Oops - somehow the Rounded Corners module was removed during all of this. Re-uploading it fixed my problem.

dzahler’s picture

jimmb, I just came across this post...

In the future, I would add the following to the module's .info file:

dependencies[] = rounded_corners

This will ensure that rounded corners is enabled before enabling your module and thereby eliminating the chance of having the last error.

jimmb’s picture

Thanks for the advice David. I just added that to my .info file...

Regards,

Jim

john franklin’s picture

The easier way to use this module is to add the code snippet to THEME_preprocess() in your theme's template.php file.

pcambra’s picture

Status: Fixed » Active

In the wiki documentation states that you can add this in the preprocess of your template, but I couldn't get it working, only in a custom module's hook_init, is this right?

amitaibu’s picture

> only in a custom module's hook_init, is this right?

No, you can put it on any function you want -- hook_init will make sure it will happen on every page, but that is not always the case. The advantage of turning this module into an API, is that it can be conditionally loaded.

You can also add it in your template.php preprocess, but you might need to add this line in the end of that function:

   $vars['scripts'] = drupal_get_js();

See more about this here -- http://www.drupaler.co.uk/blog/joys-preprocessing/70

mshepherd’s picture

Just to tie together some of the posts above.

I've got this working by adding the following into my theme's template.php file. If you use this, change MYTHEME to the name of your theme. Also, be sure to use an appropriate selector. I used '#block-views-nodequeue_1-block li'

function MYTHEME_preprocess_page() {
  $commands = array();
  $commands[] = array('selector' => '.selector');
  // Add the rounded corners.
  rounded_corners_add_corners($commands);
  $variables['scripts'] = drupal_get_js();
}

My theme is a subtheme of Fusion core, so I had to create a template.php in my subtheme's directory.

I have another subtheme of this subtheme and it was comforting to notice that my rounded corners were correctly inherited by the sub-subtheme.

jdln’s picture

The last post works for me, but how can I apply rounded corners to a 2nd div?
Thanks

jdln’s picture

Works with this:

function eyetohandtheme_preprocess_page() {
  $commands = array();
  $commands[] = array('selector' => '#div1', 'width' => 10);
  $commands[] = array('selector' => '.div2', 'width' => 10);
  // Add the rounded corners.
  rounded_corners_add_corners($commands);
  $variables['scripts'] = drupal_get_js();
}
optimusprime619’s picture

are there further details on the commands array options we pass for the rounded corners, similar to the original js in malsup site?

jdln’s picture

If I understand what you saying then yes, i think so. Look at this from the documentation:

http://groups.drupal.org/node/5455

To apply round corners with a 10px radius to all corners of all blocks, you would use:
$(".block").corner("round 10px");

To apply round corners to only the top of blocks:
$(".block").corner("round top 10px");

Round corners on top, and bevelled on bottom:
$(".block").corner("round top 10px");
$(".block").corner("bevel bottom 10px");

To apply round corners to only blocks in your right sidebar.
$("#sidebar-right .block").corner("round top 10px");
mshepherd’s picture

Just to expand a little on my previous post - here's an example of how you can add further options and more than one selector:

function MYTHEME_preprocess_page() {
  $commands = array();
  $commands[] = array('selector' => '.content-region-inner',
                    'effect' => 'round',
                    'corners' => 'all',
                    'width' => 15);
  $commands[] = array('selector' => '#block-menu-primary-links ul.menu li a',
                    'effect' => 'round',
                    'corners' => 'all',
                    'width' => 15);
  $commands[] = array('selector' => '#footer-inner',
                    'effect' => 'round',
                    'corners' => 'bottom',
                    'width' => 15);
  $commands[] = array('selector' => '#header-group-inner',
                    'effect' => 'round',
                    'corners' => 'top',
                    'width' => 15);

  // Add the rounded corners.
  rounded_corners_add_corners($commands);
  $variables['scripts'] = drupal_get_js();
}

Hope that helps.

optimusprime619’s picture

hi thanks for the details...just like above i targeted my anchor tag like

'selector' => 'ul#tabs li a' ,
'corners' => 'top', 

but the rounded corner effects all the four corners and not just the top left and right corners....so was wondering what i might've done wrong..happens both on IE7 and FF 3.6, though one with extra div's and the other with -moz-border-radius on all 4 corners..being a noob that i am one would never know if its me who's doing things wrong or if its something else... :)

pitxels’s picture

My drupal alerted me to update this module to the 6.x-3.0-alpha1, so I did just to find out this is broken, and there is no UI, where is the improvement here? This module was working ok, why not make a different module for that API?

Of course I can use the old version, but why promoting an upgrade?

I am really thankful for version 6.x-2.0

tonyhrx’s picture

I was used to version 2 also and had a bit of a headache trying to get the new one to work. The best advice is at 23 - works fine.

One problem with the version 2 was that it completely broke CiviCRM javascript functions so the new one, though a bit obscurely documented is a better version for that reason alone.