Drupal

I need little help with a small PHP snippet for a computed field

Drupal Module Development - Wed, 2010-06-09 00:37

Greeting,

Please help, because I know that many people are looking for a solution to something like this, while there is no helper module.

Here's the scenario:

I have a site where people submit URL links to external articles, powered by Drigg module.
I want to take the full URL address submitted in the $form['url'] field, strip away the http:// or http://www. , strip away everything that comes after the .com and then, take the new clean word example.com and store it in the database as a taxonomy tag. In effect, I hope to have taxonomy tags which pull together all the submitted articles from a given external domain.

To achieve this, I'm trying to use the Computed Field module, which allows us to enter PHP snippets and calculate a new field from values entered in another field.

$url is something that comes from the Drigg module, and it's the full external URL of an article

So far I know how to strip away the http:// or http://www. and everything that comes after the .com with this code:
$myurl = preg_replace('%^(https?://[^/]*).*%', '\1', $url);
$mydomain = str_replace('http://', '',str_replace('http://www.', '', $myurl ) );
which works fine in my theme. Then...

read more

Categories: Drupal

Need Drupal Gardens 7.x API's for LinkedIn search and VigorCRM.

Drupal Module Development - Tue, 2010-06-08 21:39

Need Drupal Gardens 7.x API's for LinkedIn search and VigorCRM.

Categories: Drupal

Delete query not working

Drupal Module Development - Tue, 2010-06-08 20:09

In my module I'm using the following code to remove a row from my database:

<?php
function lesplanning_delete_form_submit($form_state){
    if(db_query("DELETE FROM {docent_availability} WHERE id ='%s'", $form_state['values']['id'])){
        drupal_set_message('Het verwijderen is gelukt');
    }else{
        drupal_set_message("Het verwijderen is niet gelukt. Probeer het nog een keer of neem contact op met de beheerder als het probleem zich blijft voordoen.");
    }

}
?>

At first everything seems to work fine. The query isn't really executed though, causing no change to the db. I'm sort of clueless on what the reason could be so any advice is welcome.

Thanks in advance,

Bouke

Categories: Drupal

Own cck field

Drupal Module Development - Tue, 2010-06-08 19:56

Hi,

i am coding a contrubute module /custom cck field. But i am stuck at the point where i want my files to be uploaded to a folder outside the public html folder. I want them to be for example in /var/files. It does not work because the working directory is still the sites/default/files dir (checked that with getcwd() ), even if i pass /var/files to file_move (to move them out of the temp dir).

I read the sourcode of a module that does save its files outside the public html, it uses something like:

global $conf;
$system_directory_path = $conf['file_directory_path'];
$system_file_downloads = $conf['file_downloads'];
$mymodule_directory_path = variable_get('mymodule_private_directory_path', $system_directory_path);
$mymodule_file_downloads = FILE_DOWNLOADS_PRIVATE;

...... operations and code and then sets the paths back.

$conf['file_directory_path'] = $system_directory_path;
$conf['file_downloads'] = $system_file_downloads;

I think that does not look very clean. Is there another way without manipulating the global $conf at runtime of the module?

any ideas?

thank you

marco

Categories: Drupal

Drupal7 File stream wrappers - where is file_get_contents() or file_load_data()?

Drupal Module Development - Tue, 2010-06-08 18:59

I'm working through a module upgrade, and hit a bit of a standstill with the Drupal 7 file wrappers.

Simple case - I use file_save_upload() to upload a file from a form.
It creates a temporary, sorta-virtual file and tells me:

stdClass Object
(
    [uid] => 1
    [status] => 0
    [filename] => faqTerms.rdf
    [uri] => temporary://faqTerms.rdf
    [filemime] => application/rdf+xml
    [filesize] => 1162
    [source] => file_upload
    [destination] => temporary://faqTerms.rdf
    [timestamp] => 1276023082
    [fid] => 6
)
Um, right.
So how do I read the contents of this uploaded file?

I can't see any read function in the public API, although there is a file_save_data() going the other way.

Is this a gap in the Drupal 7 API? Do I have to do it by hand?

I see in stream_wrappers.inc a declaration of stream_read() ... but where's good old file_get_contents() or equivalent?

For now, it seems I can go
<?php
  $file->filepath = drupal_realpath($file->uri);
  $data = file_get_contents($file->filepath);
?>
... but it feels like that is entirely undermining the point of the stream wrappers.

So what am I missing?

Categories: Drupal

File Redirect Module: Use File API?

Drupal Module Development - Tue, 2010-06-08 18:06

Hi

First, I am looking for a module that allows the admin setup that all file uploads by users are redirected to a storage location outside of the Drupal website.

However, if such module does not exist, then as a head-start, is File API the best starting place?: http://drupal.org/node/555118

Are there known File API samples or tutorials?

Thanks

Categories: Drupal

ProssimaFermataGenova.it - case study

Drupal Showcase - Tue, 2010-06-08 17:18
Prossima Fermata Genova

http://www.prossimafermatagenova.it

Background

The town of Genoa (Italy) in the last few years has focused his attention on digital media and the "web 2.0" phenomenon, realizing several interesting activities under the Genova Città Digitale (i.e. Genoa Digital City) project. Among those: the The Genoa Municipality Channel on YouTube, the Genoa on Facebook network, the Genova HUB on MySpace and the creation of a network of WiFi hotpots all over the city.

read more

Categories: Drupal

Retrieving data using json

Drupal Module Development - Tue, 2010-06-08 15:08

Hi,

I have a question for drupal json, for example on the server side I have a code that will get like 10 images fetched then feed the data back via ajax using drupal_json.

currently the workflow:

1 post -> 10 images fetched -> 10 images passed via json -> 10 images displayed at once.

is it possible to have this?

1 post-> 1 image fetched -> 1 image passed via json -> 1 image displayed at once -> refetched another image without doing another post loop until all 10 image is shown one by one

Categories: Drupal

Ask for quotation: import an attachment on multipl nodes

Drupal Module Development - Tue, 2010-06-08 13:52

I need quotation to build a module that will import an attachment on selected multiple nodes.

Categories: Drupal

Problem with the file_directory_path() function

Drupal Module Development - Tue, 2010-06-08 13:36

Hi guys,

I've got a problem with the file_directory_path() function.

It always returns the path of a directory named "resources" which I’ve created in 'sites\default\files'. However, other directories have been created and should be used.

This causes a serious problem when I want to use the file_create_url() function which also uses the file_directory_path() function (=> malformed URL : sites/default/files/resources/sites/default/files/entities/file.png)

What can be done about it ?

Thanks for helping !

C:\wamp\www\mySite\sites\default\files>dir
Volume in drive C has no label.
Volume Serial Number is D041-0B2A

Directory of C:\wamp\www\mySite\sites\default\files

05/18/2010  07:29 PM    <DIR>          .
05/18/2010  07:29 PM    <DIR>          ..
03/30/2010  05:54 PM                93 .htaccess
03/21/2010  07:14 PM    <DIR>          .svn
06/08/2010  12:43 PM    <DIR>          entities
02/13/2010  12:08 PM    <DIR>          images
06/08/2010  02:18 PM    <DIR>          resources
               1 File(s)             93 bytes
               6 Dir(s)     366,759,936 bytes free

Categories: Drupal

Maphilight not working

Drupal Module Development - Tue, 2010-06-08 13:07

I have installed lastest Maphilight plugin for D6 along iwth jquery plugin. Works fine in FireFox, but in IE8 i get following javascript error:
Webpage error details

User Agent: Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.0; Trident/4.0; SLCC1; .NET CLR 2.0.50727; Media Center PC 5.0; .NET CLR 3.5.30729; .NET CLR 3.0.30729)
Timestamp: Tue, 8 Jun 2010 12:57:24 UTC

Message: Invalid argument.
Line: 1
Char: 1166
Code: 0
URI: http://candc.local.co.uk/sites/all/modules/jquery_plugin/jquery.maphilig...
(this is from http://plugins.jquery.com/project/maphilight)

Message: '$.fn.maphilight' is null or not an object
Line: 36
Char: 32
Code: 0
URI: http://candc.local.co.uk/properties/Highlands-and-Islands/All/All/______...

However if I goto http://davidlynch.org/js/maphilight/docs/demo_usa.html in IE8 it works fine.

Could the issue be the fact that the demo is using jquery-1.4.2.min.js whereas via drupal my site is using a diff version of jquery:

Note: I have included
in head section of my drupal page.

Categories: Drupal

I think there's a bug in db_last_insert_id()

Drupal Module Development - Tue, 2010-06-08 10:51

UPDATE: the issue has reappeared, so I opened a bug here.

Hello good people,

Can anyone confirm this 6.x core bug?

This code returns a wrong ID.

db_query("INSERT INTO {boxes} (body, info, format) VALUES ('%s', '%s', %d)", "Some body here...", "A title is here", 1);
  $delta = db_last_insert_id('boxes', 'bid');

Now delta should have the maximud id of the {boxes} table, right?

Well this is wrong.

Currently the problematic function looks like that:
function db_last_insert_id($table, $field) {
  return db_result(db_query('SELECT LAST_INSERT_ID()'));
}

As you can see there's no use of the two input parameters.

I had to rewrite the function as follows.

function db_last_insert_id($table, $field) {
$result = db_query("SELECT $field FROM {$table} ORDER BY $field DESC LIMIT 1");
$row = db_fetch_object($result);
// print($row->$field);
return $row->$field;
}

Now this works.

Please correct me if I did some mistake.

Thanks

Categories: Drupal

Site agency of the real estate

Drupal Showcase - Tue, 2010-06-08 10:46

I wrote site for agency of the real estate What do you think about this site?

Categories: Drupal

Theming a module page

Drupal Module Development - Tue, 2010-06-08 10:15

Hi there,

I'm creating a drupal module. In one page of the module i need to remove the left sidebar and header just need a separate template file for a page.

Please suggest how can i do that.

Thank you in advance.

Categories: Drupal

Drupal functions in AJAX

Drupal Module Development - Tue, 2010-06-08 09:43

I'm currently working on a module to load some views-results in a window on the page when click/hovering them.

I'd like to know whats the standard/best way of loading drupal functions in an ajax request to I can for example do a node_load and some other stuff in a custom .php file?

Curently I'm just getting the entore page with ajax (written something within a hook_menu to get what I want, so I have my php code) and then cut off the html I don't need.
Obviously a very bad way of coding, especially for an image heavy site.

So, best way to load drupal's functions in ajax?

Categories: Drupal

How does my template know that a valid form has been successfully submitted?

Drupal Module Development - Tue, 2010-06-08 09:11

Hi there,

I'm fairly news to Drupal and have followed the steps in the tutorial here: http://hokuten.net/2010/drupal-creating-an-e-mail-subscription-block/ in order to build a newsletter subscription block for my website consisting of two simple required fields: name and email. I want to be able to know for sure in my template that the user has successfully submitted a valid form and that their details have been saved to the database.

In the tutorial I've been following, the following code in the submit function sets a message which can be read by the template:

drupal_set_message('Thanks for subscribing!');

Ideally I need a boolean variable that I can check in the template that tells me that the form has been saved.

Any ideas?

Categories: Drupal

module for rearranging of nodes

Drupal Module Development - Tue, 2010-06-08 08:58

Is there any module for rearranging of nodes by using drag and drop options.can any one please tell which one is best????
Iam having videos as a content type that should be uploaded as a node and fetching all the videos by using views,so i need to rearrange the order by using drag and drop options.
If any body know the module please help me!!!!!

Categories: Drupal

how to add new topic and date list to left-button block?

Drupal Module Development - Tue, 2010-06-08 07:36

dear all drupal user

I want to add news date and title of the news to a left-content block, my page have three block (1. left 2. center 3. right ) in one page

here is example
date title
2010/06/08 3 people dead in protest at Bangkok
2010/06/07 3 people dead in protest at Bangkok
2010/06/04 3 people dead in protest at Bangkok
2010/06/03 3 people dead in protest at Bangkok

how could i do ?
please help me.
sonarat

Categories: Drupal

Email Module

Drupal Module Development - Tue, 2010-06-08 07:03

Hi,

I have to manage the email templates for the dynamic users. I am searching a suitable module for this but did not get any luck so far.
Can anybody suggest me a suitable module for this.

Thanks in advance.

Regards,
Tonny

Categories: Drupal

Manage Email Templates

Drupal Module Development - Tue, 2010-06-08 06:39

Hey Guys,

I have to manage the email templates ( i.e HTML content ) from the Administrator of drupal. I will have to send emails to our users daily. Now I am searching for a suitable module through which we can easily able to edit the HTML.
Please suggest me any suitable drupal module for this or how can I manage this in drupal.
I've searched for this for quite a while - without success.

Best regards,
Tonny

Categories: Drupal