Skip to main content
improved formatting; Post Made Community Wiki
Source Link
avpaderno
  • 97.9k
  • 15
  • 164
  • 284

Get url path of node URL path using entity query

I'm trying to figure out how I canwant to get the path of a node path/URL via entity query. So far I've managed to fetch the title of the node but I can seem to find a solution on how to get the node path/url. Here is a sample of my code

$facultyPostings = $query->get('node')
                           ->condition('status', 1, '=')
                           ->condition('type', 'careers')
                           ->condition('field_career_directory', 'Faculty Postings', '=')
                           ->sort('created')
                           ->execute();

foreach ($facultyPostings as $key => $faculty_postings_careers) {


     $careersNode = _nodeLoad($faculty_postings_careers);



    $variables['faculty_postings'][$key]['title'] = $careersNode->get('title')->value;
    $variables['faculty_postings'][$key]['path'] = $careersNode->get('path')->value;
}
$facultyPostings = $query->get('node')
  ->condition('status', 1, '=')
  ->condition('type', 'careers')
  ->condition('field_career_directory', 'Faculty Postings', '=')
  ->sort('created')
  ->execute();

foreach ($facultyPostings as $key => $careers) {
  $careersNode = _nodeLoad($careers);
  $variables['faculty_postings'][$key]['title'] = $careersNode->get('title')->value;
  $variables['faculty_postings'][$key]['path'] = $careersNode->get('path')->value;
}

Get url path of node using entity query

I'm trying to figure out how I can get the path of a node via entity query. So far I've managed to fetch the title of the node but I can seem to find a solution on how to get the node path/url. Here is a sample of my code

$facultyPostings = $query->get('node')
                           ->condition('status', 1, '=')
                           ->condition('type', 'careers')
                           ->condition('field_career_directory', 'Faculty Postings', '=')
                           ->sort('created')
                           ->execute();

foreach ($facultyPostings as $key => $faculty_postings_careers) {


     $careersNode = _nodeLoad($faculty_postings_careers);



    $variables['faculty_postings'][$key]['title'] = $careersNode->get('title')->value;
    $variables['faculty_postings'][$key]['path'] = $careersNode->get('path')->value;
}

Get node URL path using entity query

I want to get a node path/URL via entity query. So far I've managed to fetch the title of the node.

$facultyPostings = $query->get('node')
  ->condition('status', 1, '=')
  ->condition('type', 'careers')
  ->condition('field_career_directory', 'Faculty Postings', '=')
  ->sort('created')
  ->execute();

foreach ($facultyPostings as $key => $careers) {
  $careersNode = _nodeLoad($careers);
  $variables['faculty_postings'][$key]['title'] = $careersNode->get('title')->value;
  $variables['faculty_postings'][$key]['path'] = $careersNode->get('path')->value;
}
Source Link
user77193
user77193

Get url path of node using entity query

I'm trying to figure out how I can get the path of a node via entity query. So far I've managed to fetch the title of the node but I can seem to find a solution on how to get the node path/url. Here is a sample of my code

$facultyPostings = $query->get('node')
                           ->condition('status', 1, '=')
                           ->condition('type', 'careers')
                           ->condition('field_career_directory', 'Faculty Postings', '=')
                           ->sort('created')
                           ->execute();

foreach ($facultyPostings as $key => $faculty_postings_careers) {


     $careersNode = _nodeLoad($faculty_postings_careers);



    $variables['faculty_postings'][$key]['title'] = $careersNode->get('title')->value;
    $variables['faculty_postings'][$key]['path'] = $careersNode->get('path')->value;
}