Keyword

Override k2 item administrator

  • andrea
  • andrea's Avatar Topic Author
  • Offline
  • Junior Member
More
8 years 2 months ago - 8 years 2 months ago #156458 by andrea
Override k2 item administrator was created by andrea
hi there,
i've tried to make a override on administrator/components/com_k2 items and item to show a custom fields from database mysql.

If i try with new item the url with administrator/index.php?option=com_k2&view=item doesn't work, instead, if edit an existent items, the url administrator/index.php?option=com_k2&view=item&cid=597 work.

The problem seems: if is the variable $_GET is set is displayed without problems otherwise it is not displayed.
Anyone can help me?

Thank your, regards.
A.
Last edit: 8 years 2 months ago by andrea.

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

  • Krikor Boghossian
  • Krikor Boghossian's Avatar
  • Offline
  • Platinum Member
More
8 years 2 months ago #156461 by Krikor Boghossian
Replied by Krikor Boghossian on topic Override k2 item administrator
Hello, By default a new K2 item does not have an ID assigned, thus the $_GET command will always fail until the item has been saved.

You can bypass this behaviour by assuming that if no ID is present, then it is always a new item.

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

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

  • andrea
  • andrea's Avatar Topic Author
  • Offline
  • Junior Member
More
8 years 2 months ago #156479 by andrea
Replied by andrea on topic Override k2 item administrator
Hello Krikor and thank for your reply.

The problem is just that.
Our custom field should be displayed in both ways either with or without the get and not only with the $_GET variable present in the url.

Can i fix it? How i can bypass?
Thank you,
A.

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

  • Krikor Boghossian
  • Krikor Boghossian's Avatar
  • Offline
  • Platinum Member
More
8 years 2 months ago #156482 by Krikor Boghossian
Replied by Krikor Boghossian on topic Override k2 item administrator
It's a simple if/else statement.
if($_GET['cid']) {

else { 

}

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

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

  • andrea
  • andrea's Avatar Topic Author
  • Offline
  • Junior Member
More
8 years 2 months ago #156489 by andrea
Replied by andrea on topic Override k2 item administrator
The statement if/else is useless.

I would like know why the page default.php get the template only with$ _GET setted?? Else the template doesn't load.


The template loaded in administrator/templates/isis/com_k2/item/default.php only with $_GET setted.

I hope I was clear.
Regards

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

  • Krikor Boghossian
  • Krikor Boghossian's Avatar
  • Offline
  • Platinum Member
More
8 years 2 months ago #156491 by Krikor Boghossian
Replied by Krikor Boghossian on topic Override k2 item administrator
The $_GET is almost the same as if($this->row->id):

These parts are there to determine if an item has an id, thus if it is not a new item.

If your code is inside an if($this->row->id): check, it will not be executed if the item is a new one.

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