Jump to:
| Project: | Job Posting |
| Version: | 6.x-1.9 |
| Component: | Code |
| Category: | support request |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | closed (fixed) |
Issue Summary
This following refers to the file "job_posting.module" and I'm trying to change the fields displayed on the job listing page.
Within the function job_posting_list_nodes() for each database record retrieved info is added to the $listings variable.
I understand this is done by node_view() as shown in the code below.
while ($item = db_fetch_object($result)) {
$listings .= node_view(node_load($item->nid), TRUE);
}
</pre>However, I'm trying to work out how to change the fields returned? I believe node_load($item->nid) gets all fields for the given node ID. But how do you change the fields returned by node_view?
For example, what makes the "Employer name" be displayed on the listing but not the "URL" or "Contact"?
Further, I can get the teaser to appear in the listing as follows but I'm sure this is not the right way.
while ($item = db_fetch_object($result)) {
$listings .= node_view(node_load($item->nid), TRUE);
//** Two lines below added as demonstration
$temp = node_load($item->nid);
$listings .= $temp->teaser;
}
</pre>
Comments
#1
I would just like to add thanks for this great module!
#2
You're probably making this more complicated than you need to. Examine the templates (job-posting-node.tpl.php and job-posting-list.tpl.php) and it should become clear. HTH.
#3
...oh, and possibly, the 'preprocess' functions in job_posting.module as well.
#4
Hi gmarus,
Thanks so much!
I'm a Drupal novice and had incorrectly assumed that:
However, I now realise "job-posting-node.tpl.php" handles which fields are displayed on both pages and the $page variable is used within "job-posting-node.tpl.php" to determine which additional fields to display on the detailed job page.
Further, by adding a line to the function template_preprocess_job_posting_node_display(&$variables) within the job_posting.module as below:
$variables['summary'] = $variables['node']->teaser;</pre>The auto generated summary/teaser of the body becomes available for use within "job-posting-node.tpl.php". For example the below will display it only on the job listing page.
<?php if (!$page): ?><div class="job-posting-summary">
<?php print $summary; ?>
</div>
<?php endif; ?>
</pre>
This module is really great!!!
#5