Hi there !

It's me again n again :p

Got a hook_theme():

function idea_theme($existing, $type, $theme, $path) {

    $items['page_accueil'] = array(
        'render element' => 'form',
        'template' => 'page-accueil-form',
        'path' => drupal_get_path('theme', 'idea') . '/templates',
    );

    return $items;
}

So when I call http://localhost/idea_site/page_accueil
I can see my form named 'page-accueil-form'!

But how to get it on the front page please?
I mean I want to display my form in this url: http://localhost/idea_site

Comments

pixi’s picture

Got a problem with my theming form...
hook_theme():

function idea_theme($existing, $type, $theme, $path) {

    $items['page_accueil'] = array(
        'render element' => 'form',
        'template' => 'page-accueil-form',
        'path' => drupal_get_path('theme', 'idea') . '/templates',
    );
    return $items;
}
   

/templates/page-accueil-form.tpl.php:

      <?php 
	 hide($form['accueil']['title']);
        ?>
    
    <div class="title">
      <?php print render($form['accueil']['finalite']); ?>
    </div>
	
    <?php print drupal_render_children($form); ?>

What's wrong with this plz?

pixi’s picture

up?

jaypan’s picture

What's wrong with this plz?

How are we supposed to know? You didn't tell us.

Contact me to contract me for D7 -> D10/11 migrations.

pixi’s picture

hook_theme():

function idea_theme($existing, $type, $theme, $path) {

    $items['page_accueil'] = array(
        'render element' => 'form',
        'template' => 'page-accueil-form',
        'path' => drupal_get_path('theme', 'idea') . '/templates',
    );
    return $items;
}

/templates/page-accueil-form.tpl.php:

      <?php 
	 hide($form['accueil']['title']);
        ?>
    
    <div class="title">
      <?php print render($form['accueil']['finalite']); ?>
    </div>
	
    <?php print drupal_render_children($form); ?>

and in page_accueil.form.inc:

function page_accueil_form(){

  $query = 'SELECT finalite, thematique.libelle AS THEMATIQUE, objectif.libelle AS OBJECTIF, idee.id, reponse.reponse AS REPONSE FROM {idee} ';
  $query.= 'LEFT JOIN {thematique} ON(thematique.id = idee.id_thematique) LEFT JOIN {objectif} ON(objectif.id = idee.id_objectif) ';
  $query.= 'LEFT JOIN {reponse} ON(idee.id = reponse.id_idea)';
  

  $results = db_query($query)
          ->fetchAssoc();
		  
  foreach ($results as $key => $result){
	
	$form['accueil']['finalite'] = array(
	    '#markup' => t($results['finalite']),
		'#prefix' => '<div class="thumbnail"><div class="caption">',
		'#suffix' => '</div>',
    );					
												
   	$path = $results['REPONSE'];
    $form['accueil']['img'] = array(
	    '#markup' => t('<img src="'.file_create_url($path).'" height="150px" width="200px" />'),
		'#prefix' => '<div class="panel-body">',
		'#suffix' => '<div class="panel-footer">',
    );
   
    $form['accueil']['thematique'] = array(
	    '#markup' => t($results['THEMATIQUE']),
    );
   
    $form['accueil']['objectif'] = array(
	    '#markup' => t($results['OBJECTIF']),
		'#suffix' => '</div></div></div>',
    );
	
   }
	
   return $form;
}
pixi’s picture

I tried with this hook_theme() too:

   function idea_theme($existing, $type, $theme, $path) {

    $items['page_accueil'] = array(
        'render element' => 'form',
        'template' => 'page-accueil-form',
	'path' => drupal_get_path('theme', 'idea') . '/templates',
	'file'  => drupal_get_path('module', 'page_accueil') . '/includes/page_accueil.form.inc',
	'function' => 'page_accueil_form',
    );
    return $items;
}
jaypan’s picture

Ok.

I'm guessing that you are expecting something to happen, and it isn't happening.

How are we supposed to know what that is?

Contact me to contract me for D7 -> D10/11 migrations.

pixi’s picture

OK sorry Jaypan...

I'm trying to theme my form.

I don't understand why I can't see my template "page-accueil-form" ^^

jaypan’s picture

What are you seeing?

Contact me to contract me for D7 -> D10/11 migrations.

pixi’s picture

It's ok now.

I added:
$form['#theme'] = 'page_accueil_form';
in /templates/page-accueil-form.tpl.php

and a hook_menu():

function page_accueil_menu() {

  $items = array();
  $items['page_accueil'] = array(
    'title' => 'Page d\'accueil',
    'page callback' => 'drupal_get_form',
    'page arguments' => array('page_accueil_form'),
    'access arguments' => array('access content'),
	'access callback' => TRUE,
    'file' => 'includes/page_accueil.form.inc',
    'type' => MENU_CALLBACK,
	
  );
  
  return $items;
}

in my page_accueil.module :)

This tutorial helped me : http://harshal-techapps.blogspot.fr/2011/03/drupal-7-hooktheme-template-...

Thank You too, Jaypan ;)