drupal-7drupal-content-types

Getting all the content of a content type in drupal7


I made a content type name as Jobs in drupal 7 and in Jobs content type i have added multiple multiple contents now i want to get all the content types which are related to jobs. Can it be possible using custom query or any inbuilt drupal function or module..

Please Suggest

Thanks in advance !!


Solution

  • You can easily get a list of all your content types "jobs" contents you created by using Views module. From there, you can do a lot of scenarios but it depends on your final goal.

    Programmatically, you can search for all your conten types "jobs" existing in your DB within a hook or whatever you are doing.

    $query = new EntityFieldQuery();
    $result = $query->entityCondition('entity_type', 'node')
      ->entityCondition('bundle', 'jobs')
      ->execute();
    $nodes = node_load_multiple(array_keys($result['node']));
    

    Hope it helped.