- Posts: 60
COMMUNITY FORUM
Creating one k2 item (article) for two languages
- Sori
-
Topic Author
- Offline
- Senior Member
It is quite some time I am tackling this idea and I have somehow made it possible but not quite what I want.
I want to create one k2 item and have it in two languages. (English and Farsi here).
I want two titles for one item to be displayed in its appropriate language mode. For item context or description, I can have both English and Farsi at the same place and I don't mind that but it will also help to have that separate as well.
The reason I want this and why i think it will be useful for others as well is that it can reduce the time and implications you write an item.
What I did till now was that I created an extra field called English title and put it right below the Farsi title. and I deleted the title from category blog. in this way, I have at least an English title for my international visitors but it's not ideal since I cannot also have an English title for the category blog.
you can see what I have done here and also see each item.
example category:
bahramabedini.ir/en/photogram
bahramabedini.ir/fa/photogram
example item:
bahramabedini.ir/en/photogram/855-mazichal-forest
summary: What would you suggest I should do to have two titles for each item in item view and blog view mode?
Please Log in or Create an account to join the conversation.
- Sori
-
Topic Author
- Offline
- Senior Member
- Posts: 60
I mean the file that has declares the "k2TableValue"
So I can duplicate that and assign a new database to it.
Then where should I modify the database?
Sorry, this is my first time meddling Joomla in this level.
Please Log in or Create an account to join the conversation.
- Sori
-
Topic Author
- Offline
- Senior Member
- Posts: 60
class TableK2Item extends K2Table
{
var $id = null;
var $title = null;
var $titleEN =null;
where else should I add and how can I add this value in the k2_item database structure?
I don't see any add value in my phphmyadmin
Please Log in or Create an account to join the conversation.
- Sori
-
Topic Author
- Offline
- Senior Member
- Posts: 60
I found at the bottom of the structure view there is an add column after "". So I added the titleEN to it.
Please Log in or Create an account to join the conversation.
- Sori
-
Topic Author
- Offline
- Senior Member
- Posts: 60
Thanks
Please Log in or Create an account to join the conversation.
- Krikor Boghossian
-
- Offline
- Platinum Member
- Posts: 15920
This seems like an overkill since Joomla! already offers multilingual capabilities.
By using native features you won't have to go through all this hassle.
If you want to add extra elements to the view (visible by eveyrone) simply add extrafields and render them in your template separetely with the appropriate markup.
github.com/kricore/Advanced-templating-with-K2/blob/master/_inc/cheatsheet.php#L168-L173
JoomlaWorks Support Team
---
Please search the forum before posting a new topic :)
Please Log in or Create an account to join the conversation.
- Sori
-
Topic Author
- Offline
- Senior Member
- Posts: 60
Yes my plan was not easy.
I saw the code you mentioned.
So mean I could render the specific extrafield I want in a blog view for example. right?
That might be good. I want to give it a try.
Please Log in or Create an account to join the conversation.
- Sori
-
Topic Author
- Offline
- Senior Member
- Posts: 60
<!--English Title-->
<?php if( isset( $this->item->extraFields->Englishtitle->value ) && ( $this->item->extraFields->Englishtitle->value !== '') )
<a href="<?php echo $this->item->link; ?>">
<h3 class="catItemTitle"><?php echo $this->item->extraFields->Englishtitle->name; ?></h3>
<h3 class="catItemTitle"><?php echo $this->item->extraFields->Englishtitle->value; ?></h3>
</a>
<?php endif; ?>
Please Log in or Create an account to join the conversation.
- Krikor Boghossian
-
- Offline
- Platinum Member
- Posts: 15920
<?php if( isset( $this->item->extraFields->Englishtitle->value ) && ( $this->item->extraFields->Englishtitle->value !== '') ): ?>
JoomlaWorks Support Team
---
Please search the forum before posting a new topic :)
Please Log in or Create an account to join the conversation.
- Sori
-
Topic Author
- Offline
- Senior Member
- Posts: 60
I fixed it.
Now I don't have syntax error but no extrafield either.
Please Log in or Create an account to join the conversation.
- Krikor Boghossian
-
- Offline
- Platinum Member
- Posts: 15920
JoomlaWorks Support Team
---
Please search the forum before posting a new topic :)
Please Log in or Create an account to join the conversation.
- Sori
-
Topic Author
- Offline
- Senior Member
- Posts: 60
it is awesome!
Thanks a lot, you are the best!
the alias was correct. I had not set the extrafields to show in category settings.
Please Log in or Create an account to join the conversation.
- Krikor Boghossian
-
- Offline
- Platinum Member
- Posts: 15920
JoomlaWorks Support Team
---
Please search the forum before posting a new topic :)
Please Log in or Create an account to join the conversation.