Keyword

Creating one k2 item (article) for two languages

  • Sori
  • Sori's Avatar Topic Author
  • Offline
  • Senior Member
More
6 years 8 months ago - 6 years 8 months ago #167131 by Sori
Hi,

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?
Last edit: 6 years 8 months ago by Sori.

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

  • Sori
  • Sori's Avatar Topic Author
  • Offline
  • Senior Member
More
6 years 8 months ago - 6 years 8 months ago #167140 by Sori
Can you please let me know which file in the administrator section asks for the item's title field?
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.
Last edit: 6 years 8 months ago by Sori.

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

  • Sori
  • Sori's Avatar Topic Author
  • Offline
  • Senior Member
More
6 years 8 months ago #167144 by Sori
I started by adding $titleEn in the tables.
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
  • Sori's Avatar Topic Author
  • Offline
  • Senior Member
More
6 years 8 months ago #167145 by Sori
I know it is becoming like an itinerary but it helps for a future reply of yours. (not that I expect anyone to reply fast)

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
  • Sori's Avatar Topic Author
  • Offline
  • Senior Member
More
6 years 8 months ago #167151 by Sori
Could I ask what do the files in the element folder do?
Thanks

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

  • Krikor Boghossian
  • Krikor Boghossian's Avatar
  • Offline
  • Platinum Member
More
6 years 8 months ago #167160 by Krikor Boghossian
Replied by Krikor Boghossian on topic Creating one k2 item (article) for two languages
Hello,

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
  • Sori's Avatar Topic Author
  • Offline
  • Senior Member
More
6 years 8 months ago #167174 by Sori
Thanks for your reply.

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
  • Sori's Avatar Topic Author
  • Offline
  • Senior Member
More
6 years 8 months ago #167176 by Sori
I am inserting this in catergory_item.php and I get a syntax error
<!--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; ?>
where do you think the problem might be?

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

  • Krikor Boghossian
  • Krikor Boghossian's Avatar
  • Offline
  • Platinum Member
More
6 years 8 months ago #167185 by Krikor Boghossian
Replied by Krikor Boghossian on topic Creating one k2 item (article) for two languages
It should be:
<?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
  • Sori's Avatar Topic Author
  • Offline
  • Senior Member
More
6 years 8 months ago #167194 by Sori
Thanks for your reply.

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.


Powered by Kunena Forum