Drupal lets you view unpublished content

I inherited the site Druapl5, and it will show the content when it is published, not verified in the "Publish Settings" section in the "Edit Content Form" section.

I confirmed that the status is 0 in the database for node. Therefore, it should not be visible.

My first assumption was that I logged in and why I could see it, but I logged out and I could still see it. I tried a different browser and the same, so not so.

In addition, unpublished sites appear in search results, which I initially thought was an outdated search cache, but could be something else.

Ever seen anything like this? Any ideas?

+3
source share
5 answers

You mentioned in a comment that Content Access is installed on the site. This module (as well as some others, such as ACLs ) override the default Drupal node access mechanism to provide additional / additional fine-grained permission settings.

, . , ( ). / - ​​ . readme.txt , .

, , node. , , ( , ).

+3

? , , , .

, , .

+2

. , :

admin/content/ node " ".

, , //

+1

. , .

+1

hook_node_access(). , . .

And this is not the best solution. But if you need something in between, you can always put this code in the node.tpl.php file:

if(!$node->status && $user->uid != 1){

with code added:

<div id="node-<?php print $node->nid; ?>" class="node<?php if ($sticky) { print ' sticky'; } ?><?php if (!$status) { print ' node-unpublished'; } ?> clear-block">

<?php print $picture ?>
<?php

if(!$node->status && $user->uid != 1){

?>
<?php if ($page == 0): ?>
  <h2><a href="<?php print $node_url ?>" title="<?php print $title ?>"><?php print $title ?></a></h2>
<?php endif; ?>

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

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

  <div class="content">
    <?php print $content ?>
  </div>

<?php
  if ($links) {
    print $links;
  }
}//if for published node
?>

</div>
0
source

Source: https://habr.com/ru/post/1720924/


All Articles