I am working on a classified sites with 8 different categories: For Sale, Housing, Personals etc.
When I go to the Submit ad page, I always have the same fields no matter what type of ad I would like to submit. For example the Price field is applicable to the For Sale category but not to the Personals. Is there a way I can make that field "go away" on the Submit ad page when a user selects Personals category for example. The only way I can think of is to use 8 different ed_classified modules for the 8 different categories and add the appropriate fields to the module. That way each category would have a seperate Submit ad page. So how where in the classified ad module do I need to make this changes? Thanks.

Files: 
CommentFileSizeAuthor
#8 ed_classified_content_types02.patch23.12 KBTriskelion
FAILED: [[SimpleTest]]: [MySQL] Unable to apply patch ed_classified_content_types02.patch. This may be a -p0 (old style) patch, which is no longer supported by the testbots.
[ View ]
#7 ed_classified_content_types01.patch17.59 KBTriskelion
FAILED: [[SimpleTest]]: [MySQL] Unable to apply patch ed_classified_content_types01.patch. This may be a -p0 (old style) patch, which is no longer supported by the testbots.
[ View ]
#6 ed_classified_content_types00.patch9.13 KBTriskelion
FAILED: [[SimpleTest]]: [MySQL] Unable to apply patch ed_classified_content_types00.patch. This may be a -p0 (old style) patch, which is no longer supported by the testbots.
[ View ]

Comments

Triskelion’s picture

What you want is accomplished with a hack.

1. Create new content type 'for_sale' with a price field. Associate the 'Classified Ads' vocabulary with this content type.

2. In ed_classified.module (about line 530) modify hook node_info:

function ed_classified_node_info() {
  // beware: these must match nodeapi value; name must be same as $node->type for spam module to add spam reporting links
  return array(EDI_CLASSIFIED_MODULE_NAME =>
               array('name' => t('Classified Ads'), // cannot call node_get_types() since it ends up calling this code.
                     'module' => EDI_CLASSIFIED_MODULE_NAME,
                     'description' => t('Contains a title, a body, and an administrator-defined expiration date')),
               'for_sale' =>
               array('name' => t('For Sale'),
                     'module' => EDI_CLASSIFIED_MODULE_NAME,
                     'description' => t('Classified ad with a price field.')));
}

3. If you have direct access to your database, execute the following query:
UPDATE node_type SET module='ed_classified' WHERE type='for_sale';

If you do not have access, add it as an update in ed_classified.install, and run the database update script. Remember to REMOVE the update after you have run it.

Be aware that limiting the content type to particular terms may not be trivial, so you may end up with Personals using the For Sale format :-) Hope this helps.

EDIT:

It may be sufficient just to modify node_type, without hacking hook node_info. Once the content typ is defined in the node_type table, core node info loads it. You can edit the content type without the module field being reset.

Maybe as a feature request for the module -> An admin screen listing user-defined node types, with check boxes to associate them with the ed_classified module.

Triskelion’s picture

Two points:

1. I just confirmed that hook node_info must be changed. A more general solution to my previous is:

/**
* Implementation of hook_node_info().
*/
function ed_classified_node_info() {
  $info = array();
  // beware: these must match nodeapi value; name must be same as $node->type for spam module to add spam reporting links
  $sql = "SELECT type, name, description FROM {node_type} WHERE module = '%s'";
  $result = db_query($sql, EDI_CLASSIFIED_MODULE_NAME);
  while ($type = db_fetch_object($result)) {
    $info["$type->type"] = array( 'name' => t($type->name), 'module' => EDI_CLASSIFIED_MODULE_NAME, 'description' => t($type->description));
  }
  $info[EDI_CLASSIFIED_MODULE_NAME] =      
               array('name' => t('Classified Ads'), // cannot call node_get_types() since it ends up calling this code.
                     'module' => EDI_CLASSIFIED_MODULE_NAME,
                     'description' => t('Contains a title, a body, and an administrator-defined expiration date'));
  return $info;
}

2. If you do NOT associate the new node type with the Classified Ads vocabulary, you can associate a default term with the node using Taxonomy Defaults at http://drupal.org/project/taxonomy_defaults, and the user has no control over the taxonomy. Works like a charm with ed_classified.

mcurry’s picture

@triskelion:

What you want is accomplished with a hack.

Wow, thanks for that bit of effort.

mcurry’s picture

Maybe as a feature request for the module -> An admin screen listing
user-defined node types, with check boxes to associate them with the
ed_classified module.

That's kind of what I was thinking... thanks for the suggestion, I'll investigate (unless you have a patch ready to go, of course!)

Triskelion’s picture

@inactivist

Your welcome, and thanks for the feedback. Coming from the developer, it means a lot!

I just finished a patch for lm_paypal which will preserve its legacy API, and gives the site developer the choice of using node->status to control publication. #362438: Node->status implementation for LM PayPal I am now looking at your module to see if I can do the same.

I would like to find a way to associate lm_paypal subscriptions with paid classifieds, letting lm_paypal handle all the expiry stuff and user communication, while letting ed_classified continue to work on its own, as designed, for the free stuff.

If lyricnz finds the patch worthy and can be convinced to commit it to the D5 dev branch, this might be the beginning of the 'tighter integration with lm_paypal" you mention on the project page. I already have paid classifieds working well in the sandbox.

The only problems I see with the above issue is the 'Create New Add' link still goes to the generic content type. (I know that term-specific links are in your to-do list.) With multiple content types, in the short term, users can be directed to the different types using menu items, and it is not difficult to do a static change to the current link to take the user to a page which gives them a choice.

Thanks for the great module, and I hope you don't mind my fiddling with it.

Triskelion’s picture

Version:5.x-1.5-8» 5.x-1.x-dev
Component:Documentation» Code
Status:Active» Needs review
StatusFileSize
new9.13 KB
FAILED: [[SimpleTest]]: [MySQL] Unable to apply patch ed_classified_content_types00.patch. This may be a -p0 (old style) patch, which is no longer supported by the testbots.
[ View ]

I have rolled an initial patch against the D5 dev version. Not quite ready for prime time, but it does everything discussed above.

I ran into a problem with validation using drupal_get_form as a menu callback, so I created callback functions at the top of ed_classified_settings.inc. This approach has the advantage of your being able to include additional page content without having to wrap it in form markup.

You will notice that I split your admin page in two. I wanted to make sure I was doing things correctly, and the result is a tabbed admin menu.

I have confirmed that adding a node using a user-defined content type adds the appropriate record to edi_classified_nodes, but I have not had a chance to make sure that the module handles the expiration properly.

I am currently looking at the 'Create New Ad' question. Would welcome your feedback.

Triskelion’s picture

StatusFileSize
new17.59 KB
FAILED: [[SimpleTest]]: [MySQL] Unable to apply patch ed_classified_content_types01.patch. This may be a -p0 (old style) patch, which is no longer supported by the testbots.
[ View ]

Done.

Menu items are now created for the user to add content for each user-defined content type. The Create a new ad link at the top now takes the user to a page similar to the administrators Create Content page, which gives them the choice of which ad type to use.

A couple of internal changes were required to allow all content types to be counted.

I have also added a section to README.txt explaining the use of the new functions.

Hope this proves useful.

Triskelion’s picture

StatusFileSize
new23.12 KB
FAILED: [[SimpleTest]]: [MySQL] Unable to apply patch ed_classified_content_types02.patch. This may be a -p0 (old style) patch, which is no longer supported by the testbots.
[ View ]

I extended the patch to include the disabling of the ed_classified scheduling and user notification for each selected content type, if required. The default remains to have ed_classified handle these functions.

The site designer can now use Taxonomy Defaults to associate user-defined content types with each term and associate different subscriptions with one or more content types. It is now possible to have different rates for paid ads like personals and items for sale, while retaining the free lost pet or public service ads.

The new functions have all been added without changing the legacy API of the module.

LeMale’s picture

Hi,

Can anyone tell me how to remove ed_classified copyright bouton from it's pages on my site ?

Regards,

kirkhings’s picture

Has anyone tried the conditional fields module for display certain fields only for certain types? You should be able to tie the price field to only display when 'for sale' is chosen but not 'personals'. I've used it with other content types and it works awesome, no hacks required.

ajzz’s picture

Will the above code work for Drupal 6.x? Its precisely what I need on a site that is being upgraded from D5-D6.
@triskelion: a patch for D6.x would be much appreciated!

The idea (as mentioned above) is to use the module to support posting for two separate taxonomies and content types to reduce the confusion for the users when posting. For e.g. user can create content of type "Job Listing" or "Classified Ad" (which would need two content-types), each linked to separate taxonomies with their independent vocabularies. Currently, although independent taxonomies can be created for Classified content, only one content type can be exposed to the user for content creation.

milesgillham’s picture

@ajzz: I love the idea of being able to support multiple taxonomies. Definitely something to target migrating to!

Regards,

Miles

Weka’s picture

subscribe

fgm’s picture

Version:5.x-1.x-dev» 6.x-3.x-dev
Category:task» feature

5.x is no longer supported

Since this is actually a feature, bumping to current version.

fgm’s picture

Title:ed_classified module» Support multiple node types in Classified Ads

Change issue title for better findability.

I should add this will not happen for 6.x-3.0, but might happen in a later version, probably on D7 first (or only).

Status:Needs review» Needs work

The last submitted patch, ed_classified_content_types02.patch, failed testing.

sashken2’s picture

Subscribe. Multiple node types in Classified Ads for Drupal 7

kristat’s picture

I am also looking for a way to have multiple content types that can be used as classified ads in drupal 7.

mogop’s picture

is there a "Multiple node types" solution for Drupal 7 ?
or maybe - one content type but configurable / programmatic fields to choose for selected taxonomy with multi-steps or something ? ?

fgm’s picture

Not at the moment, and there will not be one in release 7.3-1.0, or in any 6.x version.

There /could/ be one in a later release, though.

UglyKidJoe’s picture

Subscibing to this with keen interest for Drupal 7.

The ability to define different fields for different category types would be incredibly useful.

For example, my site sells horses, so users need to be able to enter very specific information like breed, gender, height, disciplines etc.

Then for another category, like "equestrian services", not all of the fields relevant to "horses for sale" as above would apply here, so it would not make sense to users to see then at all.

In it's current state is is a very useful module, but with the additional functionality it would be top-notch! Thanks for the great work folks

ps. there may be a way to do this using views, so if I figure something out in the mean time I will come back and post it here.

spiritfelix’s picture

Version:6.x-3.x-dev» 7.x-3.0

Please help me to test this patch, thanks!
use_different_content_type

fgm’s picture

Status:Needs work» Closed (duplicate)