Keyword

[SOLVED] How to make change to title of item before save?

  • Hugo Lina
  • Hugo Lina's Avatar Topic Author
  • Offline
  • New Member
More
10 years 9 months ago #122274 by Hugo Lina
I need to make some modification to the title of item before it is saved and even before it gets into converting to an alias. I want to make change to it before it is used in any kind of processing by Joomla or K2.

Hope someone can suggest me a way or tell me where can I change it in php files.

Thank you...

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

  • Mohamed Abdelaziz
  • Mohamed Abdelaziz's Avatar
  • Offline
  • Platinum Member
  • Joomla Developer
More
10 years 9 months ago #122275 by Mohamed Abdelaziz
Replied by Mohamed Abdelaziz on topic Re: How to make change to title of item before save?
It is better to do it as a k2 plugin by overriding the onK2BeforeSave function.

But if you don't care to hack k2 files, you can do it by editing administrator/components/com_k2/models/item.php at line 58, directly after this line:
($row->id) ? $isNew = false : $isNew = true;

You will check whether the item is new, then modify the title, like this:
if($isNew){
     $row->title='New Title';
}

Multiple Extra Fields Groups for K2
AutoMeta for K2
Chained Fields for K2
More K2 Extensions In My Extensions Store

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

  • Hugo Lina
  • Hugo Lina's Avatar Topic Author
  • Offline
  • New Member
More
10 years 9 months ago #122276 by Hugo Lina
Thank you for suggestion.

However, I need the value of the current title, so how can I get the current title?

P/s: I want to use str_replace to modify the current title.

Thank you.

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

  • Mohamed Abdelaziz
  • Mohamed Abdelaziz's Avatar
  • Offline
  • Platinum Member
  • Joomla Developer
More
10 years 9 months ago #122277 by Mohamed Abdelaziz
Replied by Mohamed Abdelaziz on topic Re: How to make change to title of item before save?
$row->title is the current title

Multiple Extra Fields Groups for K2
AutoMeta for K2
Chained Fields for K2
More K2 Extensions In My Extensions Store

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

  • Hugo Lina
  • Hugo Lina's Avatar Topic Author
  • Offline
  • New Member
More
10 years 9 months ago #122278 by Hugo Lina
Thank you, it is solved perfectly now. :)

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


Powered by Kunena Forum