drupal

how to avoid 'out of memory' errors when programmatically generating a lot of nodes in drupal?

旧城冷巷雨未停 提交于 2019-12-24 02:14:31
问题 I'm creating about 150 nodes programmatically and running into 'out of memory' errors when doing it all in a single request. (I have a menu callback that generates the nodes and calls node_save() on them.) Example: for($i=0; $i<150; $i++) { $node = new stdClass(); $node->title="Foo $i"; $node->field_myfield[0]['value'] = "Bar $i"; ... node_save($node); } I've heard of BatchAPI, but never used it. Is that the right tool to get around this? The docs talk about timeouts, but not memory issues.

Core javascript functions to make error, warning or notice messages appear?

岁酱吖の 提交于 2019-12-24 01:09:02
问题 Does anyone know what the core drupal javascript functions are to force an error message? More importantly, it must work with Message Effects (http://drupal.org/project/messagefx). With JS Theming you can call these: (this is javascript code) Drupal.messages.set("The Message!", 'error'); But, it doesn't hook into Message Effects, and after disabling JS theming, this function no longer works. 回答1: It seems like you have asked the wrong question. The status, warning, error messages that you see

Drupal performing a query against the database

巧了我就是萌 提交于 2019-12-24 00:38:37
问题 I wish to retrieve some nids from my drupal database. I have a query that I wish to run. SELECT node.nid AS projectnid FROM node node INNER JOIN content_type_project node_data_field_project_client ON node.vid = node_data_field_project_client.vid WHERE node_data_field_project_client.field_project_client_nid = (SELECT node_data_field_profile_company.field_profile_company_nid AS company_nid FROM node node LEFT JOIN content_type_profile node_data_field_profile_company ON node.vid = node_data

Using front.tpl in Drupal 7 for another Page

爱⌒轻易说出口 提交于 2019-12-24 00:23:09
问题 Pretty straight forward question: I have page--front.tpl and page.tpl template pages in use in a drupal 7 site. However, I'd like to use page-front.tpl on one other page. Is this possible or do I need to create another .tpl page to do this. The site I'm working on is split into two sections, it's essentially two seperate websites that you can flip between whether your a consumer or business owner. So I want to use the front.tpl template for the home page of each site. Cheers. 回答1: You can add

How to implement 'category' based newsletter

こ雲淡風輕ζ 提交于 2019-12-23 23:40:04
问题 Working on my small classified site; i'd like to give the users the ability to choose some categories, for example : cars, boats and receive daily/weekly notifications based on their choices. A user that has subscribed to 'cars' category will receive daily newsletter saying 'there are 30 new interesting classifieds for you in category : cars'. Don't know where to start; 'simplenews' module seems too simple for my usage. Any idea ? 回答1: The Subscriptions module seems to do this really well. It

Drupal 5: CCK fields in custom content type

孤人 提交于 2019-12-23 20:18:58
问题 I have module that implements custom content type via NodeAPI hooks ( hook_insert , hook_update etc). I want to add CCK field to this content type and populate it via hook_nodeapi calls like create or update (to show content nodes in Views). Problem is, I cannot access CCK fields for this content type. Sure, it's enabled on "Manage Fields" page, but when I load any node of this type with Devel module, I cannot see field attribute ( field_flag ) in node object. I can see it under "Dev Render"

Drupal: customizing validation error messages

老子叫甜甜 提交于 2019-12-23 20:12:53
问题 when the user submits a custom CCK form and a field marked as REQUIRED is empty, i get a "xyz field is required.". How can i customize this message without modifying core modules? Thanks and greetings c. 回答1: Depending on the error message and how you need to change it, you may be able to use the String Overrides module to replace the string used to generate the message. Another option is to create a custom module that overrides the validation function for a particular form or field,

Generate image with Drupal imagecache before using imagecache_create_path & getimagesize

让人想犯罪 __ 提交于 2019-12-23 18:59:09
问题 I'm using imagecache_create_path() and getimagesize() to get the path of a imagecache-generated image and its dimensions. However, if it's the first time we access the page that image doesn't exist yet and imagecache_create_path doesn't generate it either. Here's the code: // we get the image path from a preset (always return the path even if the file doesn't exist) $small_image_path = imagecache_create_path('gallery_image_small', $image["filepath"]); // I get the image dimensions (only if

How to authenticate against Django from Drupal?

半世苍凉 提交于 2019-12-23 18:44:02
问题 I have a medium sized Drupal 6 site running (around 5 million page views per month and more than 30K registered users) and I need to integrate OSQA, a Django application, with it. I already have many users, roles and permissions in my Drupal database and I'd like to point the Django app to use the sign up and login pages I already have in Drupal to give my users a single point on entrance. I want to keep the Django authentication part because I think OSQA would work better. I also have

drupal 6: how to get data from a custom module in to a template file

早过忘川 提交于 2019-12-23 17:54:26
问题 im using a custom module to create the contents of my homepage at example.com/frontpage. in the module i run a query that gets the data i need, in an array. when i return theme('page', $my_array) i get the "homepage inside the homepage", ie the default drupal logo and sitename is displayed a second time in the main content area. what's the best way to go about this, create a specific tpl.php file, the contents of which should be ... ? i realise its a very general question but in 2 hours of