I made an AHAH-based Ad type switcher. It allows to choose Ad type during the addition step. Sub-content types no more needed to create ads.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

neochief’s picture

Also included minor fix for ad_text (see patch's tail).

neochief’s picture

FileSize
7.58 KB

Ah, sorry, as ussual, missed some gotcha. Here's a better version.

neochief’s picture

FileSize
8.07 KB

Even better one.

neochief’s picture

FileSize
8.07 KB

Possibly final.

Jeremy’s picture

Status: Needs review » Needs work

When applying this patch, ad creation is overwhelmed with PHP notices which were previously fixed. Some samples:

    * notice: Undefined property: stdClass::$adtype_select in /var/www/ad69/sites/default/modules/ad/ad.module on line 618.
    * notice: Undefined property: stdClass::$adtype in /var/www/ad69/sites/default/modules/ad/ad.module on line 631.
    * notice: Undefined property: stdClass::$nid in /var/www/ad69/sites/default/modules/ad/ad.module on line 655.
    * notice: Undefined property: stdClass::$adstatus in /var/www/ad69/sites/default/modules/ad/ad.module on line 655.
    * notice: Undefined property: stdClass::$adstatus in /var/www/ad69/sites/default/modules/ad/ad.module on line 660.
    * notice: Undefined property: stdClass::$adstatus in /var/www/ad69/sites/default/modules/ad/ad.module on line 660.
    * notice: Undefined property: stdClass::$adstatus in /var/www/ad69/sites/default/modules/ad/ad.module on line 660.
    * notice: Undefined property: stdClass::$adstatus in /var/www/ad69/sites/default/modules/ad/ad.module on line 660.
    * notice: Undefined property: stdClass::$adstatus in /var/www/ad69/sites/default/modules/ad/ad.module on line 660.
    * notice: Undefined property: stdClass::$adstatus in /var/www/ad69/sites/default/modules/ad/ad.module on line 660.
    * notice: Undefined property: stdClass::$nid in /var/www/ad69/sites/default/modules/ad/ad.module on line 685.

When I try and select the advertisement type, I get an error too big to display on my screen and the ad type is not selected. It starts as follows:

An error occurred. 
/ad69/node/add/ad/ahah
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en" dir="ltr">
  <head>
    <title>Create Advertisement | localhost</title>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link rel="shortcut icon" href="/ad69/misc/favicon.ico" type="image/x-icon" />
    <link type="text/css" rel="stylesheet" media="all" href="/ad69/modules/node/node.css?K" />
<link type="text/css" rel="stylesheet" media="all" href="/ad69/modules/system/defaults.css?K" />
<link type="text/css" rel="stylesheet" media="all" href="/ad69/modules/system/system.css?K" />
<link type="text/css" rel="stylesheet" media="all" href="/ad69/modules/system/system-menus.css?K" />
<link type="text/css" rel="stylesheet" media="all" href="/ad69/modules/user/user.css?K" />
<link type="text/css" rel="stylesheet" media="all" href="/ad69/themes/garland/style.css?K" />
<link type="text/css" rel="stylesheet" media="print" href="/ad69/themes/garland/print.css?K" />
    <script type="text/javascript" src="/ad69/misc/jquery.js?K"></script>
<script type="text/javascript" src="/ad69/misc/drupal.js?K"></script>
<script type="text/javascript" src="/ad69/misc/tabledrag.js?K"></script>
<script type="text/javascript" src="/ad69/misc/jquery.form.js?K"></script>
<script type="text/javascript" src="/ad69/misc/ahah.js?K"></script>
<script type="text/javascript" src="/ad69/misc/progress.js?K"></script>
<script type="text/javascript" src="/ad69/misc/autocomplete.js?K"></script>
<script type="text/javascript" src="/ad69/misc/collapse.js?K"></script>
<script type="text/javascript" src="/ad69/misc/textarea.js?K"></script>
<script type="text/javascript">
<!--//--><![CDATA[//><!--
jQuery.extend(Drupal.settings, { "basePath": "/ad69/", "ahah": { "edit-adtype-submit": { "url": "/ad69/node/add/ad/ahah", "event": "mousedown", "keypress": true, "wrapper": "adtype-ahah-wrapper", "selector": "#edit-adtype-submit", "effect": "none", "method": "replace", "progress": { "type": "throbber" }, "button": { "op": "Select" } }, "edit-attach": { "url": "/ad69/upload/js", "event": "mousedown", "keypress": true, "wrapper": "attach-wrapper", "selector": "#edit-attach", "effect": "none", "method": "replace", "progress": { "type": "bar", "message": "Please wait..." }, "button": { 

Finally, the "fix" for the ad_text module seems to be totally unrelated to this patch -- please open a new issue and explain how it is a fix. What problem is it fixing?

Jeremy’s picture

These notices were evidently introduced earlier by me in the 6.x-2.x-dev branch. I am fixing them to address another bug, and hope to commit the fix soon. I will retry your patch at that time.

Jeremy’s picture

Repeating my question from before: "the 'fix' for the ad_text module seems to be totally unrelated to this patch -- please open a new issue and explain how it is a fix. What problem is it fixing?"

Jeremy’s picture

This patch still doesn't work -- when I try selecting an ad type, I get a full screen of errors as described above. Note that I have enabled PHP E_ALL, and as the module is nearly 100% working with E_ALL I don't want to fall back to having it not work in this configuration.

I can not merge this patch until it works.

neochief’s picture

Status: Needs work » Needs review
FileSize
6.92 KB

I rerolled patch, but I still have nothing with E_ALL enabled. Everything works just fine.

Jeremy’s picture

When I go to "Create Content -> Advertisement" I see the following:

    * notice: Undefined property: stdClass::$adtype_select in /var/www/ad69/sites/default/modules/ad/ad.module on line 620.
    * notice: Undefined property: stdClass::$adtype in /var/www/ad69/sites/default/modules/ad/ad.module on line 633.

When I try to actually select an ad type, I get more errors that fits on my screen, and as it's a popup I'm unable to scroll it for all of the errors. They start as follows:

An error occurred. 
/ad69/node/add/ad/ahah
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en" dir="ltr">
  <head>
    <title>Create Advertisement | localhost</title>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link rel="shortcut icon" href="/ad69/misc/favicon.ico" type="image/x-icon" />
    <link type="text/css" rel="stylesheet" media="all" href="/ad69/modules/node/node.css?N" />
<link type="text/css" rel="stylesheet" media="all" href="/ad69/modules/system/defaults.css?N" />
<link type="text/css" rel="stylesheet" media="all" href="/ad69/modules/system/system.css?N" />
<link type="text/css" rel="stylesheet" media="all" href="/ad69/modules/system/system-menus.css?N" />
<link type="text/css" rel="stylesheet" media="all" href="/ad69/modules/user/user.css?N" />
<link type="text/css" rel="stylesheet" media="all" href="/ad69/themes/garland/style.css?N" />
<link type="text/css" rel="stylesheet" media="print" href="/ad69/themes/garland/print.css?N" />
    <script type="text/javascript" src="/ad69/misc/jquery.js?N"></script>
<script type="text/javascript" src="/ad69/misc/drupal.js?N"></script>
<script type="text/javascript" src="/ad69/misc/tabledrag.js?N"></script>
<script type="text/javascript" src="/ad69/misc/jquery.form.js?N"></script>
<script type="text/javascript" src="/ad69/misc/ahah.js?N"></script>
<script type="text/javascript" src="/ad69/misc/progress.js?N"></script>
<script type="text/javascript" src="/ad69/misc/autocomplete.js?N"></script>
<script type="text/javascript" src="/ad69/misc/collapse.js?N"></script>
<script type="text/javascript" src="/ad69/misc/textarea.js?N"></script>
<script type="text/javascript">
<!--//--><![CDATA[//><!--
jQuery.extend(Drupal.settings, { "basePath": "/ad69/", "ahah": { "edit-adtype-submit": { "url": "/ad69/node/add/ad/ahah", "event": "mousedown", "keypress": true, "wrapper": "adtype-ahah-wrapper", "selector": "#edit-adtype-submit", "effect": "none", "method": "replace", "progress": { "type": "throbber" }, "button": { "op": "Select" } }, "edit-attach": { "url": "/ad69/upload/js", "event": "mousedown", "keypress": true, "wrapper": "attach-wrapper", "selector": "#edit-attach", "effect": "none", "method": 

I am unable to select an ad type with this patch applied.

Jeremy’s picture

I also note that when I'm at "node/add/ad" if I try and click one of the ad types from the navigation menu this is ignored by the AHA code. If I browse to "node/add/ad/text" I would expect it to give me a form for creating a text ad, but it does not.

Jeremy’s picture

Even after disabling E_ALL, I still get the full screen of errors described in #10 above and the AHA ad type selector does not work for me.

Jeremy’s picture

Status: Needs review » Needs work
neochief’s picture

Status: Needs work » Needs review
FileSize
6.82 KB

Here's notices fix. As for big error — just clean the drupal cache.

Jeremy’s picture

Status: Needs review » Fixed

Awesome! It is now working perfectly for me. I update ad.install to automate flushing the cache as this will evidently be necessary for everyone.

Patch committed. Thanks!!

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

m4olivei’s picture

See #1064940: Ad type AHAH switcher does not pass form through form_alter for an issue that I found with this patch. Any feedback would be appreciated.

bora-89’s picture

hey there,
How about that one: http://drupal.org/node/757124