# W każdy czwartek o 22:00 #
Spotkania ludności drupal.pl na IRC- odpal czat -
- dedykowany temat na forum -

drupal.pl w sieci Google!

Shoutbox

You're not permitted to post shouts.
DepecheMati

Widać, że pracownikom Google się nudzi - http://bit.ly/L6pAsn :-}

1 dzień 9 godzin ago
grzegorz.bartman

Wybiera się ktoś na DrupalCon do Monachium?

2 dni 9 godzin ago
malcolm

No, wspomnień czar ;)

6 dni 7 godzin ago
spamator12

@Mati thx :P
@malcolm gdzieś o tym słyszałem i to z tego forum nie pamiętam... Gra się w to jak w stare setlersy ?

6 dni 8 godzin ago

Permalink - ale jako #1,#2,#3

14 odpowiedzi [Ostatni wpis]
kerios83
Portret użytkownika kerios83
Offline
Dołączył: 12.01.2011
Postów:
  • Drupal 7

Jak to zgrzebac zarowno na forum jak i w komentarzach ?

DepecheMati
Portret użytkownika DepecheMati
Offline
Kraków
Dołączył: 22.04.2010
Postów:
AdministratorModeratorOpętany przez diabła kasuje bez opamiętania!
kerios83
Portret użytkownika kerios83
Offline
Dołączył: 12.01.2011
Postów:

Dzieks ! Le teraz zczailem ze to do 6 jest. Mam siodemeczke.

DepecheMati
Portret użytkownika DepecheMati
Offline
Kraków
Dołączył: 22.04.2010
Postów:
AdministratorModeratorOpętany przez diabła kasuje bez opamiętania!

W 7 takie cuś już jest :] Funkcja $permalink wykorzystana np: w comments.tpl skórki Bartik.

kerios83
Portret użytkownika kerios83
Offline
Dołączył: 12.01.2011
Postów:

Noo chodzi mi o to co jest na tym forum - kazdy post w topiku dostaje #1,#2,#3 itd.

Zaraz zerkne do tej templatki i przeniose do swojej.

EDIT: Po przenosinach nadal jest twardy permalink, zamiast #1... Malo tego w bartiku tez nie ma #numer tylko permalink. Rozumiem, ze trzeba cos tam dodac ?

DepecheMati
Portret użytkownika DepecheMati
Offline
Kraków
Dołączył: 22.04.2010
Postów:
AdministratorModeratorOpętany przez diabła kasuje bez opamiętania!

NIe znam D7 na tyle, ale skoro tak się wyświetla (może Ci się nie udało) to dodaj sobie na końcu linka ID komentarza czy posta i włala.

DepecheMati
Portret użytkownika DepecheMati
Offline
Kraków
Dołączył: 22.04.2010
Postów:
AdministratorModeratorOpętany przez diabła kasuje bez opamiętania!
kerios83
Portret użytkownika kerios83
Offline
Dołączył: 12.01.2011
Postów:

Oto caly kod z comment.tpl bartika 7

<div class="<?php print $classes; ?> clearfix"<?php print $attributes; ?>>

  <div class="attribution">

    <?php print $picture; ?>

    <div class="submitted">
      <p class="commenter-name">
        <?php print $author; ?>
      </p>
      <p class="comment-time">
        <?php print $created; ?>
      </p>
      <p class="comment-permalink">
        <?php print $permalink; ?>
      </p>
    </div>
  </div>

  <div class="comment-text">
    <div class="comment-arrow"></div>

    <?php if ($new): ?>
      <span class="new"><?php print $new; ?></span>
    <?php endif; ?>

    <?php print render($title_prefix); ?>
    <h3<?php print $title_attributes; ?>><?php print $title; ?></h3>
    <?php print render($title_suffix); ?>

    <div class="content"<?php print $content_attributes; ?>>
      <?php
       
// We hide the comments and links now so that we can render them later.
       
hide($content['links']);
        print
render($content);
     
?>

      <?php if ($signature): ?>
      <div class="user-signature clearfix">
        <?php print $signature; ?>
      </div>
      <?php endif; ?>
    </div> <!-- /.content -->

    <?php print render($content['links']); ?>
  </div> <!-- /.comment-text -->
</div>

Jezeli dobrze to rozumiem to Drupal zlicza komentarze posty jeden po 2 wiec numery nijak maja sie do zawartosci danego topiku czy komentarzy w artykule - bedzie:

DANY TOPIK:

#345

#367

#373

zamiast:

#1

#2

#3

EDIT:

Niestety nie dziala. Peramlink sie ladnie w 7 wyswietla chodzi tylko o to aby inaczej wygladal zamiast - permalink walil # i po kolei dodawal wartosci (W DANYM TOPIKU/KOMENTARZU).

malcolm
Portret użytkownika malcolm
Offline
macroom (Ireland)
Dołączył: 28.07.2010
Postów:
Moderator

W advanced_forum jest to rozwiązanie więc dodaj sobie do template.php :

function SKÓRA_preprocess_comment(&$variables){
/* Linked post number */
  if (!isset($post_number)) {
    static $post_number = 1;
  }

  $posts_per_page = variable_get('comment_default_per_page_' . $node->type, 50);

  $page_number = !empty($_GET['page']) ? $_GET['page'] : 0;
  if (!$page_number) {
    $page_number = 1;
  }

  $post_number++;

  $linktext = '#' . (($page_number * $posts_per_page) + $post_number);

  // Permalink
  //  You can erase next 3 lines if you wish to use built-in Permalink.
  //  Template adjusted: $post_link -> $permalink
      $uri = entity_uri('comment', $comment);
  $uri['options'] += array('attributes' => array('class' => 'permalink', 'rel' => 'bookmark'));
  $variables['permalink'] = l($linktext, $uri['path'], $uri['options']);
}

Lub zainstaluj advanced forum jeśli tylko do forum jest Ci to potrzebne.

kerios83
Portret użytkownika kerios83
Offline
Dołączył: 12.01.2011
Postów:

Działa ale tylko częściowo, zamienia permalinka na #numer, ale jest to numer danego komentarza a nie numer w stylu ARTYKUL i teraz komentarz w nim zaczyna sie od #1 i leci przy czym kazdy nastepny w tym artykule to +1. W dodatku link nie dziala.

EDIT: po zmianie page number na 0:

  $page_number = !empty($_GET['page']) ? $_GET['page'] : 0;
  if (!$page_number) {
    $page_number = 0;
  }

numeracja sie zgadza. Jednak link kierujacy do komentarza jest zwalony.

malcolm
Portret użytkownika malcolm
Offline
macroom (Ireland)
Dołączył: 28.07.2010
Postów:
Moderator

To masz cały kod wklej w preprocess_comment i kombinuj ;)

/* Easy links to the comment and parent node */
  $comment = $variables['comment'];
  $node = node_load($comment->nid);
  $variables['first_post'] = $node;

  // This is a comment, not the node.
  $variables['top_post'] = FALSE;

  /* Determine the template file to use for the comment. */
  if (arg(1) == 'reply' || arg(1) == 'edit') {
    // Use the preview version
    advanced_forum_add_template_suggestions("post-preview", $variables);
  }
  else {
    // Use our combined node/comment template file
    advanced_forum_add_template_suggestions("post", $variables);
  }

 
  // Add in our classes overwriting existing.
  $variables['classes_array'] = array(); 
  $variables['classes_array'][] = 'forum-post clearfix';

  // Add the current language to the classes for image handling.
  global $language;
  if (!empty($language->language)) {
    $variables['classes_array'][] = $language->language;
  }

  // Add the poster's UID
  $variables['classes_array'][] = "posted-by-$comment->uid";

  // Add class if the poster is the viewer.
  global $user;
  if ($user->uid > 0 && $user->uid == $comment->uid) {
    $variables['classes_array'][] = "post-by-viewer";
  }

  // Add class if the poster is the topic starter.
  if ($node->uid > 0 && $node->uid == $comment->uid) {
    $variables['classes_array'][] = "post-by-starter";
  }

  // Set the post ID for theming / targetting
  $variables['post_id'] = "post-$comment->cid";

  /* Linked post number */
  if (!isset($post_number)) {
    static $post_number = 1;
  }

  $posts_per_page = variable_get('comment_default_per_page_' . $node->type, 50);
 
  $page_number = !empty($_GET['page']) ? $_GET['page'] : 0;
  if (!$page_number) {
    $page_number = 0;
  }
 
  $post_number++;

  $linktext = '#' . (($page_number * $posts_per_page) + $post_number);
 
  // Permalink
  //  You can erase next 3 lines if you wish to use built-in Permalink.
  //  Template adjusted: $post_link -> $permalink
  $uri = entity_uri('comment', $comment);
  $uri['options'] += array('attributes' => array('class' => 'permalink', 'rel' => 'bookmark'));
  $variables['permalink'] = l($linktext, $uri['path'], $uri['options']);

  /* In reply to */
  $variables['in_reply_to'] = "";
  if ($comment->pid > 0) {
    // Find the display position of the parent post;.
    $post_position = advanced_forum_post_position($node->nid, $comment->pid);
  
    // This extra if test is a sanity check in case the comment being replied
    // to no longer exists.
    if ($post_position > 0) {
      // Find the page the post is on. We need to compensate for the topic node
      // being #1 which puts an extra post on the first page but not on the rest.
      $page_number = floor(($post_position - 2) / $posts_per_page);

      // Assemble the link.
      $fragment = 'comment-' . $comment->pid;
   
      if ($page_number)
        $query = array('page' => $page_number);
     
      $linktext = t("(Reply to #!post_position)", array('!post_position' => $post_position));
      $linkpath = "node/$node->nid";
      $variables['in_reply_to'] = l($linktext, $linkpath, array('query' => empty($query) ? array() : $query, 'fragment' => $fragment));
    }
  }

  /* Title */
  if (variable_get('comment_subject_field_' . $node->type, 1) == 0) {
    // if comment titles are disabled, don't display it.
    $variables['title'] = '';
  }
  else {
    // Assign the subject to the title variable for consistancy with nodes.
    $variables['title'] = check_plain($comment->subject);
  }

  /* User information / author pane */
  if ($comment->uid == 0) {
    // Anonymous user. Make a fake user object for theme_username
    $variables['account']->name = empty($comment->name) ? "" : $comment->name;
    $variables['account']->homepage = empty($comment->homepage) ? "" : $comment->homepage;
    $variables['account']->email = empty($comment->email) ? "" : $comment->email;
  }
  else {
    // Load up the real user object
    $variables['account'] = user_load($comment->uid);
  }

  // Create the author pane
  if (module_exists('author_pane')) {
    $variables['author_pane'] = theme('author_pane', array(
      'account' => $variables['account'],
      'caller' => 'advanced_forum',
      'picture_preset' => variable_get('advanced_forum_user_picture_preset', ''),
      'context' => $comment,
      'disable_css' => TRUE
    ));
  }
  else {
    $variables['author_pane'] = theme('advanced_forum_simple_author_pane', array('context' => $comment));
  }
  /* Content */
  // Helpful $content variable for templates.
  foreach (element_children($variables['elements']) as $key) {
    // Adjust content vriable to suit post template
    if ($key == 'comment_body')
      $variables['content']['body'] = $variables['elements'][$key];
    else
      $variables['content'][$key] = $variables['elements'][$key];
  }

  /* Signatures */
  // Load the signature.
  if (module_exists('signature_forum')) {
    // If Signature For Forums is installed, use that
    $variables['signature'] = signature_forum_get_signature($comment);
  }
  elseif (variable_get('user_signatures', 0)) {
    if (!empty($variables['account']->signature)) {
      // Otherwise load Drupal's built in one, if enabled.
      $variables['signature'] = check_markup($variables['account']->signature, $variables['account']->signature_format, FALSE);
    }
  }
 
  // Adjust comment timestamp to match node template
  $variables['date'] = $variables['created'];
 
  /* Post edited */
  $variables['post_edited'] = (isset($variables['comment_edited'])) ? $variables['comment_edited'] : "";

Teraz działa na pewno ;)