- Posts: 7
COMMUNITY FORUM
- Forum
- K2 Community Forum
- English K2 Community
- [SOLVED] How to make change to title of item before save?
[SOLVED] How to make change to title of item before save?
- Hugo Lina
- Topic Author
- Offline
- New Member
Less
More
10 years 9 months ago #122274
by Hugo Lina
[SOLVED] How to make change to title of item before save? was created 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...
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
- Offline
- Platinum Member
- Joomla Developer
10 years 9 months ago #122275
by Mohamed Abdelaziz
Multiple Extra Fields Groups for K2
AutoMeta for K2
Chained Fields for K2
More K2 Extensions In My Extensions Store
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:
You will check whether the item is new, then modify the title, like this:
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
- Topic Author
- Offline
- New Member
Less
More
- Posts: 7
10 years 9 months ago #122276
by Hugo Lina
Replied by Hugo Lina on topic Re: How to make change to title of item before save?
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.
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
- Offline
- Platinum Member
- Joomla Developer
10 years 9 months ago #122277
by Mohamed Abdelaziz
Multiple Extra Fields Groups for K2
AutoMeta for K2
Chained Fields for K2
More K2 Extensions In My Extensions Store
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
- Topic Author
- Offline
- New Member
Less
More
- Posts: 7
10 years 9 months ago #122278
by Hugo Lina
Replied by Hugo Lina on topic Re: How to make change to title of item before save?
Thank you, it is solved perfectly now. :)
Please Log in or Create an account to join the conversation.
- Forum
- K2 Community Forum
- English K2 Community
- [SOLVED] How to make change to title of item before save?