Skip to content
Snippets Groups Projects
Commit 9c9c5b87 authored by Brian Canini's avatar Brian Canini
Browse files

php adjustments

- getting rid of unnecessary db calls in customtoken
- changing research filter if statements to isset instead of count
parent 4f3888a2
No related branches found
No related tags found
No related merge requests found
......@@ -22,10 +22,10 @@ function customtokens_token_info() {
function customtokens_tokens($type, $tokens, array $data, array $options, \Drupal\Core\Render\BubbleableMetadata $bubbleable_metadata) {
$replacements = [];
$nids = \Drupal::entityQuery('node')->condition('type','research_landing_page')->execute();
$nodes = \Drupal\node\Entity\Node::loadMultiple($nids);
$lid = array_shift(array_keys($nodes));
$lid = array_shift($nids);
$alias = \Drupal::service('path.alias_manager')->getAliasByPath('/node/'.$lid);
if ($type == 'customtoken' && !empty($data['node'])) {
foreach ($tokens as $name => $original) {
switch ($name) {
......
......@@ -156,7 +156,7 @@ function asc_bootstrap_form_alter(&$form, \Drupal\Core\Form\FormStateInterface $
*/
if (($form['#id'] == 'views-exposed-form-research-project-directory-block-1')||($form['#id'] == 'views-exposed-form-research-project-directory-page-1')) {
if(count($form['field_research_departments_target_id']['#options']['#value']) == "All") {
if(isset($form['field_research_departments_target_id']['#options']['All'])) {
// $form['field_research_departments_target_id']['#options']['All'] = $form['#info']['filter-field_research_departments_target_id']['label'];
$tarr = array_slice(array_keys($form['field_research_departments_target_id']['#options']), 1, 5, true);
$tid = array_shift($tarr);
......@@ -171,7 +171,7 @@ function asc_bootstrap_form_alter(&$form, \Drupal\Core\Form\FormStateInterface $
}
}
if(count($form['field_research_other_target_id']['#options']['#value']) == "All") {
if(isset($form['field_research_other_target_id']['#options']['All'])) {
//$form['field_research_other_target_id']['#options']['All'] = $form['#info']['filter-field_research_other_target_id']['label'];
$tarr = array_slice(array_keys($form['field_research_other_target_id']['#options']), 1, 5, true);
$tid = array_shift($tarr);
......@@ -186,7 +186,9 @@ function asc_bootstrap_form_alter(&$form, \Drupal\Core\Form\FormStateInterface $
}
}
if(count($form['field_research_year_target_id']['#options']['#value']) == "All") {
// dpm($form['field_research_year_target_id']);
if(isset($form['field_research_year_target_id']['#options']['All'])) {
//$form['field_research_year_target_id']['#options']['All'] = $form['#info']['filter-field_research_year_target_id']['label'];
$tarr = array_slice(array_keys($form['field_research_year_target_id']['#options']), 1, 5, true);
$tid = array_shift($tarr);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment