logo

Blog

21 April

Custom code to add meta tag in Drupal 7
By: admin | Published On: Tue, 04/21/2020 - 23:45

In your theme's template.php file, you could add something like **/

/** * Implements hook_preprocess_html */ 
function THEME_NAME_preprocess_html(&$vars) { 
	if (current_path() == 'my/custom/path') { 
		$description = array( 
		'#type' => 'html_tag', 
		'#tag' => 'meta', 
		'#attributes' => array( 'name' => 'description', 'content' => 'here all description goes', )
		 ); 
		 
		 drupal_add_html_head($description, 'description'); 
	} 
 }
 

21 April

Redirect Method in DRUPAL8
By: admin | Published On: Tue, 04/21/2020 - 23:44

To redirect on node add form or node creation form

$form_state->setRedirectUrl(Url::fromUri('internal:' . '/node/add/business'));

If you want to pass argument with URL

Example:

        $params['query'] = [
            'name' => $name,
            'id' => $id,
        ];
$form_state->setRedirectUrl(Url::fromUri('internal:' . '/node/add/business', $params));

Method to redirect on node id url

$url = Url::fromRoute('…