Hello and thank you for the great module!

I have a custom content type called say... "Student".
This type holds persons details like name, contacts, personal homepage and... you guessed it! a personal blog RSS feed link.

Meaning that, I would like to automatically import his/her blog posts into Drupal site.

So... instead of having these RSS links in the (default) Feed type - I have the links in my custom content type.

How do I make it so that Cron actually loops through my Students, looks for the Blog RSS field value and aggregates (pulls and saves) the data from there into Feed item?.

Any ideas or tips?

Should I use PHP and Feeds API-s for that?

Thanks,

Comments

mareks’s picture

Hold your horses ;)

I think, all I really needed to do was to change the "Attached to" settings from "Feeds" to "Student" under the "Feeds importers".

/admin/structure/feeds/feed/settings

This created me a field called "FEED" (Enter a feed URL.) for my custom content type.

So far so good,

mareks’s picture

It works!

However, the new RSS link field that was automatically created for my Student Content-type is marked as mandatory - thus... I can't save the node with an empty RSS URL field. I get an error "URL field is required".

But some students do not have a blog.

There seems to be no settings for this field?

What are my options?

form_alter ?

Thanks,

TechNikh’s picture

I fixed my issue with form alter

function module_name_form_alter(&$form, $form_state, $form_id)
{
  if ($form_id == 'page_node_form') {
    $form['feeds']['FeedsHTTPFetcher']['source']['#required'] = FALSE;
  }
}
TechNikh’s picture

looks like even validate function should be disabled. otherwise it throws below error.
The URL is invalid.

TechNikh’s picture

I had to add this to below validate function if(!empty($values['source'])){
feeds\plugins\FeedsHTTPFetcher.inc

  /**
   * Override parent::sourceFormValidate().
   */
  public function sourceFormValidate(&$values) {
    $values['source'] = trim($values['source']);
    if(!empty($values['source'])){
      if (!feeds_valid_url($values['source'], TRUE)) {
        $form_key = 'feeds][' . get_class($this) . '][source';
        form_set_error($form_key, t('The URL %source is invalid.', array('%source' => $values['source'])));
      }
      elseif ($this->config['auto_detect_feeds']) {
        feeds_include_library('http_request.inc', 'http_request');
        if ($url = http_request_get_common_syndication($values['source'])) {
          $values['source'] = $url;
        }
      }
    }
  }
Dianna L’s picture

Component: Feeds News » Code

Wow- Thanks so much for this!

Searched and searched and this finally fixed the problem for me on Drupal 6.

falster’s picture

This is a really nice solution. But is there a good way to add the if(!empty($values['source'])){ without going directly into FeedsHTTPFetcher.inc ? I don't feel like it is a good idea to hack feeds.

Anonymous’s picture

Issue summary: View changes

Can this solution be ported to D7? I have the feed-URL-field in the Drupal Blogs content type. I tried:

function modulename_form_FORM_ID_alter(&$form, $form_state, $form_id) {
    $form['feeds']['FeedsHTTPFetcher']['source']['#required'] = FALSE;

but after I add the if(!empty($values['source'])){ to the FeedsHTTPFetcher.inc I get WSOD when adding blog content.

MegaChriz’s picture

Status: Active » Closed (duplicate)

There is also an other issue about making the Feeds fetcher form optional for when attaching the importer to a content type: #856316: Add option to make source URL/file not required for importers attached to nodes, so I close this one as a duplicate.