Hi
I know that CCK compatibility is (should be) on the way, but I need to add text fields into image type ad. Is there any possible way to do this in template or even by hacking it in module? I dont need generic solution for any cck field and whole cck compatibility, I just need to add specific field to image ad and html type is not an option because my client must be able to modify/create ads.

I tried to modify block-ad.tpl.php and print my field data, but the ad content comes in one variable and it is not possible to print any more content in a block, it has to be modified before it gets into a block.

Comments

n_nelson350’s picture

Well which contributed module are you using for image? Or have you developed a different module for that.

please give me the details in more...................
Reply at the earliest possible time.

m1n0’s picture

For image I use only upload module, advertisment module uses it and thru file attachment I upload the file

david.lukac’s picture

Subscribing

SweeneyTodd’s picture

I am in the process of changing the code that displays the ads from functions to template files (.tpl.php). This will allow preprocessor functions to work and easier theming of the ads. You should be able to use this to display your cck content. I hope to post back the files in the next couple of days. I will add another comment with a link to where I have posted (use my contact form to remind me if I forget).

The other solution would be to create a new ad type with the additional field as part of the ad instead of cck. This should be a matter of an hour or 2 to code, but not a great solution if you already have a load of data input for image ads.

SweeneyTodd’s picture

I have just posted the template file (and a patch for ad_image.module) for the image ad (http://drupal.org/node/852756#comment-3200338).

I have had a look at how to add cck fields to a template file as well - I haven't actually tried this out so let me know if it works. I found this article (http://drupalib.interoperating.info/node/99) which has a template referencing cck fields. It looks like the correct form of the reference is:

  print $node->field_xxx[0]['view'];

The ad-image-ad.tpl.php file should be copied to your theme folder before editing.

Note: for this case you do not need to edit the template_preprocess_ad_image_ad function but if you decide you need to, paste it into your theme template.tpl.php file and rename it MyTheme_preprocess_ad_image_ad. Edit this copy, not one in the module.

The problem with this is that $node is not passed to the template file, so it looks like the module code is going to have to be hacked to send it (not good practice, but the only way I can see at present).

If we ask the module maintainer nicely, maybe he will add $node to all the theme function definitions for a future release to extend what can be done by theming without hacking the module code. I will log a separate issue to request this.

In the ad_image.module file (the one which my patch has been applied to), find the theme_ad_image function and change the arguments array for ad_image_ad as follows:

    'ad_image_ad' => array(
//      'file' => 'ad_image.module', // uses function ad_image_ad (above)
      'template' => 'ad-image-ad', // uses ad-image-ad.tpl.php
      'arguments' => array(
        'ad' => NULL,
        'node' => NULL,
      ),

Since the theme_ad_image_ad function is no longer used this should not cause a problem. If it does change the function definition to the following:

function theme_ad_image_ad($ad, $node)

Anyway, this will make any node properties available as part of the ad template so you can output cck fields or (the real reason I worked on this) taxonomy terms.

Have fun!

anonymous07’s picture

Subscribe

iztok’s picture

Subscribing.

n_nelson350’s picture

Use of hook_form_alter can be done in this case for whatever changes has to be made in content type fields.

Regards,
S. Nelson

lrwebks’s picture

Issue summary: View changes
Status: Active » Closed (outdated)

Drupal 6 is EOL and no longer supported. Closing this as outdated for that reason. Thanks for your contribution!