This forum is for module development and code related questions, not general module support. For general support, use the Post installation forum.

Creating a node programmatically

Hi,
my module is using the insert hook to insert nodes of type question. now i wish to create nodes with out using a node form.

I am guessing i can just create a node object of type question programmatically , alter some of its propertys and then pass it to question_insert($node) to save it. i have found node_save but no method to freshly create node objects . i also found advice to use node_aggragator but i cant find it in the api.

Is this how i should create a node ?

What functions should i use to create the fresh node object ?

Problem with block form on every page

I have been creating a module that has a form in the sidebar which queries a real estate listing service and returns the results to a page, search-results.html. The form is displayed on every page including the results page. I was having problems with the form returning results and had a sneaking suspicion that the form was redirecting and losing the _POST data, so I put a counter in the function. The form was redirecting at least twice, the counter was counting to 3 each time I searched. So I added the [#redirect] = false and it seemed to work. The problem is that it works the first time that I search from the form, but if I search again, the problem comes back. So in other words, I do a search, the form results are displayed on the results page (with the search form in the right column) but if I search again using the form the results will not be display and my counter shows that the form redirected 3 times again.

It seems that the form is having problems when the results are passed to the same page, but I don't know what to do about it.

Here is a snippet of code that I am using to create the form in the sidebar_right block:

function my_mod_block($op = 'list', $delta = 0)
{
if ($op == 'list')
{
$block[0 ]['info'] = t('MLS');
return $block;
}
else if ($op == 'view')
{

$output = "

Creating a view module

I'm looking to create a view module specifically for gathering images uploaded with imagefield, and integrating them with a spiffy little gallery script I wrote. I would also like to be able to use imagecache to resize the images so they aren't huge and so I don't have to crop all my photos.

My questions are as follows:

Can anyone tell me a good place to start? I looked around the handbook and didn't see anything about creating view modules specifically. I looked through the module hooks and nothing really popped out at me as "Oh this is what I need!"

Node creation form issue

I am adapting the joke module from the pro drupal development book. the joke
module uses the node module and hooks to do all the standard node
operations.

hook_info is used to define the joke node type.

hook_form is used for inputing the jokes nodes joke and punchlines.

a menu call back to /node/add/joke is used to allow you to call hook_form
and view the joke creation form.

i am tying to call the joke node creation form on its own so that it appears
as a local task on another node type. I have created the local task and when my local task when clicked it callsback my function my_joke_entry_page with has a call to drupal_get_form(joke_form).

But i get the error

warning: Missing argument 1 for question_form() in /home/lue/domains/londonukescorts.co.uk/www/public_html/sites/all/modules/question/question.module on line 115.

My problem is here, i do not have a node object to pass to the form, so what should i do ? and how should i pass it.


function joke_page() {
$output = t('my joke node creation form');
drupal_get_form(joke_form);
return $output;
}

function joke_form($node) {
// Get metadata for this node type
// (we use it for labeling title and body fields).
// We defined this in question_node_info().
$type = node_get_types('type', $node);

$form['title'] = array(
'#type' => 'textfield',

Parsing result of drupal_http_request

Brethren,

I've been trying to make trackback.module "autodiscover" trackbacks (see http://drupal.org/node/175801 ) through visits to my site and their referrers. This question requires no knowledge of trackback.module so feel free to assist me even if you don't know about it!

Here's the basic framework of what I'm trying to do:

1. START processing:
2. When cron runs,
3. For each row in the access_log table that accesses a Drupal node and has a referrer URL since the last time cron ran
4. Try to fetch an RSS type feed url from the referrer site.
5. If the site doesn't provide a feed url, then it's likely it's not a blog or news type site and we can stop processing.
6. If it does provide a feed url, fetch the feed and parse it.
7. For each article in that feed check whether it contains a reference to the Drupal node referred to in the access_log record.
8. If it does not contain a reference to said Drupal node we can stop processing.
9. If it does, extract an excerpt and title from the article in the feed and save the whole lot into the trackbacks_received table. It should then appear under the node on my site when it is viewed.
10. STOP processing.

Small bugfix to get Gallery module G2 sync working when 'Full Name support' is disabled

drupal 4.7.7
gallery-4.7.x-1.0.2006-Nov-14

On my Drupal site was the sync with G2 only working when profile module was enabled and Gallery 'Full Name support' too.

Looking at the code I think I found a small issue which makes the sync not working if 'Full Name support' is disabled.

In the file gallery_user.inc I modified the line 68, replacing
$user->$fullnamefield = $name;
with
$user->$fullnamefield = $user->name;

Pages

Subscribe with RSS Subscribe to RSS - Module development and code questions