hellstar képe

ez van egy node-ban php-ban: (előtte persze a kapcsolat felépítése)

 
mysql_query('SET NAMES "utf8"');
 
echo '<form id="form1" name="form1" method="post" action="ertekeles.php">';
 
echo "<b>Értékelendő lemez: </b>";
echo'<select name="lemezek">';
 
 
$res=mysql_query("select title from node where type='flexinode-1' order by title");
if(mysql_num_rows($res)==0) echo "there is no data in table..";
else
for($i=0;$i<mysql_num_rows($res);$i++) {
$row=mysql_fetch_assoc($res);
echo"<option>$row[title]</option>";
}
echo'</select>';
 
echo "<p>";
 
echo "<b>Rövid értékelés: </b>";
print ("<textarea name='szoveg'>$szoveg</textarea>");
echo "<p>";
echo "<b>Pontszám: </b>";
echo "<select name='pont'>";
for($j=1;$j<11;$j++) 
{
echo"<option>$j</option>";
}
echo'</select>';
 
 
echo "<p>";
echo "<b>Értékelő: </b>";
 
 
global $user;
print $user->name;
 
 
echo "<p>";
 
 
 
echo '<label>';
echo '<input name="&Eacute;rt&eacute;kel" type="submit" id="&Eacute;rt&eacute;kel" value="&Eacute;rt&eacute;kel" />';
echo '</label>';
echo '</form>';

Ez az ertekeles.php:

 
 
global $user
 
mysql_query('SET NAMES "utf8"');
 
mysql_query("insert into lemezhaboru (lemezcim,pont,ertekelo,ertekeles) 
values ('$_POST[lemezek]','$_POST[pont]','$user->uid','$_POST[szoveg]')");

A táblák pedig:

id tinyint(4) auto_increment
lemezcim varchar(255) utf8_general_ci
pont tinyint(4)
ertekelo varchar(255) utf8_general_ci
ertekeles varchar(255) utf8_general_ci

Arra sem jöttem rá, hogy ha az ertekeles.php lefut, akkor miért kapok tök fehér képernyőt.
Ide kéne valami includes, vagy requred a theme-ből, de nem tudom mi. (Ez már egy következő probléma...)

köszönöm hogy segítesz
Hs.

0
0
makgab képe

tudom mit akarok, csak nem találtam mintát.

De eddig jutottam, ami működik is:

<?php
 
function theme_node_example_order_info($node) {
	$output = '<div class="node_example_order_info">';
	$output .= t('The order is for %quantity %color items.', array('%quantity' => check_plain($node->quantity), '%color' => check_plain($node->color)));
	$output .= '</div>';
        $output .= l('Mailing order...','nodebase');
	return $output; 
}
 
 
function node_example_menu() {
   $items = array();
 
   $items['nodebase'] = array(
    'page callback' => 'mailing',
    'access callback' => 'user_access',
    'access arguments' => array('access content'),
    ); 
 
   return $items;
}
 
 
//** mailing
function mailing() {
  //drupal_mail('node_example', 'notice', $account->mail, user_preferred_language($account), $params);
  $output = "Mailing sending...";
  return $output;
}
 
 
/*
 * hook_mail
 */
function node_example_mail($key, &$message, $params) {
  $language = $message['language'];
  $variables = user_mail_tokens($params['account'], $language);
  switch($key) {
   case 'notice':
   $message['subject'] = t('Notification from !site', $variables, $language->language);
   $message['body'][] = t("Dear !username\n\nMessage...bla...bla...", $variables, $language->language);
   break;
   }
}
?>

A hook_link nem szükséges nekem.
Csak a drupal_mail-t kellene használnom. a $to paraméterben szeretném megadni, hogy az admin-nak menjen. Az $account váltózóban a 1-est (admin) kell megkeresni. Ott vannak a regisztrált userek?

G.

0
0
fecske95 képe

Ja közben én is bogarásztam és találtam ezt az issues-t
http://drupal.org/node/997112

a pachet kipróbáltam de hibaüzenetet adott vissza

warning: array_diff_assoc() [function.array-diff-assoc]: Argument #2 is not an array in /home1/valami/public_html/sites/all/modules/cck/includes/content.rules.inc on line 338.

ezután átvarázsoltam a cck/includes/content.rules.inc fájl alját (ugyanis az utolsó függvényről van szó ebben a fájlban) valami ilyesmire és ez most úgy tűnik működik.
Figyelembe veszi a filefiled állapotát üres nem üres...
A change eseményre továbbra sem reagál a file mező de... valahol itt lesz annak is a megoldása...
A többi eseményem, amelyek a rules kezel úgy tűnik a helyén maradt, működik.
A change és értékhez kötöttek is.

Azért engem megnyugtatna ha egy profi drupalos programozó rá tudna nézni erre a kódra... Ami igazából csak + egy feltétellel bővült:
if (is_array($sub_value) && is_array($node_value[$delta])) {

 
 
function _content_rules_field_has_value($node_value, $value) {
  if (count($value) != count($node_value)) {
    return FALSE;
  }
   // Loop over multiple fields
   foreach ($value as $delta => $sub_value) {
     // Check if all properties of the value are there in the node value too
    if (is_array($sub_value) && is_array($node_value[$delta])) { 
      if (count(array_diff_assoc($sub_value, $node_value[$delta])) != 0) {
        if (gettype($sub_value) != gettype($node_value[$delta])) {
      return FALSE;
    }
 
    if (is_array($sub_value) && is_array($node_value[$delta]) && count(array_diff_assoc($sub_value, $node_value[$delta])) != 0) {
       return FALSE;
     }
   }
    elseif ($sub_value !== $node_value[$delta]) {
      return FALSE;
    }       
   }
  } 
  return TRUE;
}  
 
 
0
0
makgab képe

Az ubercart-ból is lehet függvényeket hívni, mint a user_save() v. user_delete()?
Tehát pl. script-ből meghívható az uc_product_insert() v. uc_product_update() függvény?

<?php
function uc_product_insert($node) {
  if (!isset($node->unique_hash)) {
    $node->unique_hash = md5($node->vid . $node->nid . $node->model . $node->list_price . $node->cost . $node->sell_price . $node->weight . $node->weight_units . $node->dim_length . $node->dim_width . $node->dim_height . $node->length_units . $node->pkg_qty . $node->default_qty . $node->shippable . time());
  }
  db_query("INSERT INTO {uc_products} (vid, nid, model, list_price, cost, sell_price, weight, weight_units, length, width, height, length_units, pkg_qty, default_qty, unique_hash, ordering, shippable) VALUES (%d, %d, '%s', %f, %f, %f, %f, '%s', %f, %f, %f, '%s', %d, %d, '%s', %d, %d)",
    $node->vid, $node->nid, $node->model, $node->list_price, $node->cost, $node->sell_price, $node->weight, $node->weight_units, $node->dim_length, $node->dim_width, $node->dim_height, $node->length_units, $node->pkg_qty, $node->default_qty, $node->unique_hash, $node->ordering, $node->shippable
  );
}
?>

Megfelelően paraméterezve persze.

0
0
csg képe

Saját modul kell, és bele két függvény. Az egyikkel elérjük, hogy a mi másik függvényünk fusson le a user/%user útvonalon:

  1. /*
  2.  * Implementation of hook_menu_alter().
  3.  */
  4. function modulname_menu_alter(&$items) {
  5. $items['user/%user']['access callback'] = TRUE;
  6. $items['user/%user']['page callback'] = 'modulname_landingpage';
  7. }

A másik pedig az adminnak megmutatja a user oldalt, a többieknek pedig kiír egy általunk megadott a szöveget.

  1. /*
  2.  * User landing page.
  3.  *
  4.  * If the account is blocked, show the user page to the admin,
  5.  * and display a warning to others.
  6.  */
  7. function modulname_landingpage() {
  8. global $user;
  9. $account = user_load(1);
  10. if ($account->status === 0 && in_array('administrator', $user->roles)) {
  11. return user_view_page($account);
  12. }
  13. else {
  14. drupal_set_title(t('Go away'));
  15. return t('Sorry, this is a blocked user.');
  16. }
  17. }

Nem teszteltem, lehet benne hiba. A működésbe léptetéshez a gyorstárat üríteni kell, hogy a menü újraépüljön.

1
0

--
Csonka Gergely
http://cheppers.com

Sk8erPeter képe

„1.) Létrehoztam egy teszt.js fájlt.
2.) Abba bemásoltam a fenti kódot.”

Kapásból nem jó, direkt mondtam, hogy a Drupalos konvencióknak megfelelően rakd be a kódot (lásd behaviors). :)
Így nem akkor fog lefutni a kód, amikor kell.

Ezt fusd át:
http://drupal.org/node/756722#using-jquery
meg ezt:
http://drupal.org/update/modules/6/7#javascript_compatibility

Valahogy így rakd be a modulod JS-fájljába:

  1. (function ($) {
  2.  
  3. Drupal.behaviors.MODULODNEVECSERELDLE = {
  4. attach: function (context, settings) {
  5. var $checkboxes = $('#devel-generate-content-form td input[type="checkbox"]');
  6.  
  7. $checkboxes.change(function () {
  8. var countCheckedCheckboxes = $checkboxes.filter(':checked')
  9. .length;
  10. $('#count-checked-checkboxes')
  11. .text(countCheckedCheckboxes);
  12. });
  13. }
  14. };
  15.  
  16. })(jQuery);

„5.) A modulom.module -ban a <?php után beírtam:
drupal_add_js('/sites/all/modulom/js/teszt.js'

Megint nem jó. Csak úgy a levegőben nem lóghat a kódod. Ehhez implementálni kell pl. a hook_init() hookot. Ezenkívül az sem jó, hogy ilyen módon adod meg az útvonalat, hogy perjellel kezdődik (mi van, ha alkönyvtárban van a Drupalod?), és erre való a drupal_get_path().

Tehát valahogy így csináld:

  1. /**
  2.  * Implements hook_init()
  3.  */
  4. function MODULODNEVECSERELDLE_init(){
  5. $my_module_path = drupal_get_path('module', 'MODULODNEVECSERELDLE');
  6. drupal_add_js($my_module_path.'/js/teszt.js');
  7. }

Azt, hogy betöltődik-e a fájlod a megfelelő helyen, ne úgy csekkold, hogy átnevezed a fájlt, hogy kapsz-e file not found errort, hanem úgy, hogy megnézed a Source-t a böngészőben (általában Ctrl+U billentyűkombináció), hogy szerepel-e benne a fájl a tag src attribútumában.

A MODULODNEVECSERELDLE értelemszerűen mindenhol legyen lecserélve a saját modulod nevére.

1
0
Sk8erPeter képe

egyeLőre

Ez alapján indultam el http://techblog.zabuchy.net/2010/non-database-field-in-custom-drupal-vie... de csak részleteiben értem.

Megnéztem az általad linkelt példát, itt sehol sem használja a get_value() metódust. Te miért azzal próbálkozol?
A render() metódust használja fel, szerintem neked is azzal kellene próbálkoznod!
Az pedig így néz ki:
http://api.drupal.org/api/views/handlers%21views_handler_field.inc/funct...

  1. // ...
  2.  
  3. /**
  4.   * Render the field.
  5.   *
  6.   * @param $values
  7.   * The values retrieved from the database.
  8.   */
  9. function render($values) {
  10. $value = $this->get_value($values);
  11. return $this->sanitize_value($value);
  12. }
  13.  
  14. // ...

Tehát szerintem nálad is ezt a metódust kellene felhasználni. Elvileg itt is tudnál mit kezdeni a saját, adatbázisból jövő értékeiddel.
Nézd meg ezt a példát is (mondjuk ez már Views 3 API, de most itt nagy különbség nincs):
http://www.heididev.com/custom-field-handlers-views-3
a példa 3-as pontjában pont a render()-ben végzi el a saját adatainak tetszőleges kiíratását:

  1. class video_handler_field_video_duration extends views_handler_field {
  2.  
  3. function render($values) {
  4. if (!empty($values->video_queue_duration))
  5. return gmdate("H:i:s", $values->video_queue_duration);
  6. else
  7. return NULL;
  8. }
  9.  
  10. }
0
0
Lavjaman képe

Nah, hali megint mindenkinek

Sir_Csavar ígértem, elkészítettem ^^ használd egészséggel

Még annyi megjegyzés, hogy beletettem egy autocomplete-et is :)

<?php 
function om_kereso_menu() {
  $items = array();
  $access = array('access content');
 
  $items['om_kereso'] = array(
    'title' => t("Keresés"),
    'weight' => 0,
    'page callback' => 'om_kereso_page',
    'access arguments' => $access,
    'type' => MENU_NORMAL_ITEM
  );
 
  $items['custom/autocomplete'] = array(
    'page callback' => 'om_kereso_data_autocomplete',
    'access arguments' => $access,
    'access callback' => TRUE,
    'type' => MENU_CALLBACK,
  );
 
  return $items;
}
 
function om_kereso_form(&$form_state) {
  $form['#redirect'] = FALSE;
 
  $form['om_kereso'] = array(
    '#type' => 'textfield',
    '#title' => 'Keresés az OM title-ben',
    '#autocomplete_path' => 'custom/autocomplete'
  );
 
  $form['submit'] = array(
    '#type' => 'submit',
    '#value' => t('Mehet')
  );
 
  return $form;
}
 
 
function om_kereso_page() {
  $output = drupal_get_form('om_kereso_form');
 
  if(!empty($_POST['om_kereso'])) {
    $keresendo_szo = $_POST['om_kereso'];
    $result = db_query("SELECT n.title FROM node n WHERE n.title LIKE '%$keresendo_szo%' AND n.status = 1"); //ide jöjjön az sql lekérdezésed
 
    $items = array();
 
    while($record = db_fetch_array($result)) {
      $items[] = $record['title'];
      //ide jön az adatok összegyűjtése;
    }
    if (!empty($items)) {
      $output .= theme('item_list', $items, 'A keresés eredménye', 'ul');
 
    }
    else {
      $output .= drupal_set_message('Nem találtam a keresett szó alapján semmit se', 'status', TRUE);
    }
  }
 
  return $output;
}
 
function om_kereso_data_autocomplete($node = '') {
  $matches = array();
  $result = db_query("SELECT n.title FROM node n WHERE n.title LIKE '$node%' AND n.status = 1");
    while ($record = db_fetch_object($result)) {
      $matches[$record->title] = check_plain($record->title);
    }
  print drupal_to_js($matches);
  die;
}
?>
0
0

*----*----*

$node ? 'alma' : 'bor'

*----*----*

Lavjaman képe

Üdv megint,

Kijavítottam a hibákat, használjátok egészséggel

<?php
function om_kereso_menu() {
  $items = array();
  $access = array('access content');
 
  $items['om_kereso'] = array(
    'title' => t("Keresés"),
    'weight' => 0,
    'page callback' => 'om_kereso_page',
    'access arguments' => $access,
    'type' => MENU_NORMAL_ITEM
  );
 
  $items['custom/autocomplete'] = array(
    'page callback' => 'om_kereso_data_autocomplete',
    'access arguments' => $access,
    'access callback' => TRUE,
    'type' => MENU_CALLBACK,
  );
 
  return $items;
}
 
function om_kereso_form(&$form_state) {
  $form['#redirect'] = FALSE;
 
  $form['om_kereso'] = array(
    '#type' => 'textfield',
    '#title' => 'Keresés az OM title-ben',
    '#autocomplete_path' => 'custom/autocomplete'
  );
 
  $form['submit'] = array(
    '#type' => 'submit',
    '#value' => t('Mehet')
  );
 
  return $form;
}
 
 
function om_kereso_page() {
  $output = drupal_get_form('om_kereso_form');
 
  if(!empty($_POST['om_kereso'])) {
    $keresendo_szo = $_POST['om_kereso'];
    $result = db_query("SELECT n.title FROM {node} n WHERE n.title LIKE '%%%s%%' AND n.status = 1, $keresendo_szo"); //ide jöjjön az sql lekérdezésed
 
    $items = array();
 
    while($record = db_fetch_array($result)) {
      $items[] = $record['title'];
      //ide jön az adatok összegyűjtése;
    }
    if (!empty($items)) {
      $output .= theme('item_list', $items, 'A keresés eredménye', 'ul');
 
    }
    else {
      $output .= drupal_set_message('Nem találtam a keresett szó alapján semmit se', 'status', TRUE);
    }
  }
 
  return $output;
}
 
function om_kereso_data_autocomplete($toredek= '') {
  $matches = array();
  $result = db_query("SELECT n.title FROM {node} n WHERE n.title LIKE '%s%%' AND n.status = 1, $toredek");
    while ($record = db_fetch_object($result)) {
      $matches[$record->title] = check_plain($record->title);
    }
  print drupal_to_js($matches);
  die;
}
?>

Nyah, örvendtem

0
0

*----*----*

$node ? 'alma' : 'bor'

*----*----*

hosszu.kalman képe

Szerintem két irányból közelítheted meg a dolgot:

  1. a hook_form_alter()-t használod
  2. a template.php-t használod

A user.module-ban meg lehet nézni mi is állítja elő azt a form-ot:

function user_login_block() {
  $form = array(
    '#action' => url($_GET['q'], array('query' => drupal_get_destination())),
    '#id' => 'user-login-form',
    '#validate' => user_login_default_validators(),
    '#submit' => array('user_login_submit'),
  );
  $form['name'] = array('#type' => 'textfield',
    '#title' => t('Username'),
    '#maxlength' => USERNAME_MAX_LENGTH,
    '#size' => 15,
    '#required' => TRUE,
  );
  $form['pass'] = array('#type' => 'password',
    '#title' => t('Password'),
    '#maxlength' => 60,
    '#size' => 15,
    '#required' => TRUE,
  );
  $form['submit'] = array('#type' => 'submit',
    '#value' => t('Log in'),
  );
  $items = array();
  if (variable_get('user_register', 1)) {
    $items[] = l(t('Create new account'), 'user/register', array('attributes' => array('title' => t('Create a new user account.'))));
  }
  $items[] = l(t('Request new password'), 'user/password', array('attributes' => array('title' => t('Request new password via e-mail.'))));
  $form['links'] = array('#value' => theme('item_list', $items));
  return $form;
}

Ha a hook_form_alter-t használod, akkor $form['links']-t kell felülírnod a megfelelőre.

Ha a template.php-t használod akkor valami ilyesmit kell majd csinálni

function SMINKEMNEVE_theme() {
  return array(
    'user_login_block' => array(
      'arguments' => array('form' => NULL),
    ),
  );
}
 
function SMINKEMNEVE_user_login_block($form) {
  //meg tudod nézni mi minden van benne: print_r($form);
 
  $out  = '';
  // Módosítod a dolgokat a megfelelőre
  // A végén hozzáfűzöd ezt a sort, hogy benne legyenek a rejtett input mezők is
  $out .= drupal_render($form);
 
  return $out;
}

Ugye az egyik modul, a másik smink kérdés. Ha valami funkcionális módosítás akkor azt inkább modullal szokás megcsinálni, ha pedig kinézet akkor sminkkel.

A baj az, hogy nem értem pontosan mit szeretnél:

  1. Azt akarod hogy ne listában legyen hanem más megjelenítésben
  2. Azt akarod hogy ne is látszódjon, ne jelenjen meg

Az első esetben szerintem inkább smink kérdés, a másodikban én már modult írnék rá.

0
0