Keyword

Weiterlesen nur für angemeldete User

  • werner
  • werner's Avatar Topic Author
  • Offline
  • New Member
More
4 years 8 months ago - 4 years 8 months ago #175095 by werner
Liebes Team,
gibt es eine Möglichkeit so wie bei Joomla-Artikeln auch in K2 den weiterlesen-Link nur für z.B. angemeldete User frei zu geben...?
Vielen Dank!
Werner
Last edit: 4 years 8 months ago by werner.

Please Log in or Create an account to join the conversation.

More
4 years 8 months ago - 4 years 8 months ago #175118 by JoomlaWorks
Replied by JoomlaWorks on topic Weiterlesen nur für angemeldete User
This is actually very simple to accomplish with K2.

It requires that you override K2's item.php file (more info on overriding here: getk2.org/documentation/tutorials/templating-with-k2-and-the-concepts-of-sub-templates) to insert some additional code to handle what users who are NOT registered see.

A simplified example would be to add this at the top of the item.php file (but right after "defined('_JEXEC') or die;"):
// Get the user info
$user = JFactory::getUser();

// If the user is not registered (aka a guest), show some message, otherwise show the item's content
if ($user->guest) {
    echo '<p>You need to be registered to view this content.</p><p>You can <a href="#">sign up here</a>.</p>';
} else {
?>

<!-- the actual code for item.php continues -->

<?php
} // Here we close the if/else statement which controls what the user sees (this will be at the bottom of the item.php file)

Fotis / JoomlaWorks Support Team
---
Please search the forum before posting a new topic :)
Last edit: 4 years 8 months ago by JoomlaWorks. Reason: Fixed code typo

Please Log in or Create an account to join the conversation.

  • werner
  • werner's Avatar Topic Author
  • Offline
  • New Member
More
4 years 7 months ago #175239 by werner
Replied by werner on topic Weiterlesen nur für angemeldete User
Thank you Fotis,
but I dont know which item.php you mean...
greetings werner

Please Log in or Create an account to join the conversation.

More
4 years 7 months ago #175244 by JoomlaWorks
Replied by JoomlaWorks on topic Weiterlesen nur für angemeldete User
"item.php" is the template override for the item (article) view. That file is in /components/com_k2/templates/default/ and you can copy it INSIDE your Joomla template's html/com_k2/default/ folder (create it if it doesn't exist) and then modify it.

Read the link I posted. More info is present there.

Fotis / JoomlaWorks Support Team
---
Please search the forum before posting a new topic :)

Please Log in or Create an account to join the conversation.


Powered by Kunena Forum