Keyword

Special Characters in K2 Item Titles

  • Ryan Roberts
  • Ryan Roberts's Avatar Topic Author
  • Offline
  • New Member
More
11 years 4 weeks ago #117858 by Ryan Roberts
Special Characters in K2 Item Titles was created by Ryan Roberts
Hi All,

I need to add a subscript character to the title of a K2 post. The client is adamant that the character needs to be in there as it is the representation for a chemical compound.

I have been searching the web and these forums but as yet have only found 1 solution on this forum from over 2 years ago and it seems that code is for an earlier version of K2 as I can't find the code mentioned in the post. Or I'm just being daft and not spotting it. (getk2.org/community/New-to-K2-Ask-here-first/153233-Adding-superscript-character-to-K2-item-title)

Does anyone else know of a possible workaround for this?

It is the last thing that needs to be done before I can go live with the website so it's also causing quite an extreme headache.

Thanks
Ryan

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

  • Krikor Boghossian
  • Krikor Boghossian's Avatar
  • Offline
  • Platinum Member
More
11 years 4 weeks ago #117859 by Krikor Boghossian
Replied by Krikor Boghossian on topic Re: Special Characters in K2 Item Titles
Hello Ryan,

I would use an extrafield in your position. Since you can directly render it where you want in your template, custom code will not be an issue.

You can find a snippet in this post: getk2.org/community/New-to-K2-Ask-here-first/171284-Where-to-edit-K2-after-Item-Fields

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

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

  • Ryan Roberts
  • Ryan Roberts's Avatar Topic Author
  • Offline
  • New Member
More
11 years 4 weeks ago #117860 by Ryan Roberts
Replied by Ryan Roberts on topic Re: Special Characters in K2 Item Titles
Hi Krikor,

Thanks for the help. Managed to get it sorted on the individual article page.

However when I take that code to the user.php the page no longer works.

The code I take from item.php to user.php is as follows:
	  <?php if($this->item->params->get('itemExtraFields') && count($this->item->extra_fields)): ?>
	  <!-- Item extra fields -->
	  <div class="itemExtraFields">
			<?php foreach ($this->item->extra_fields as $key=>$extraField): ?>
			<?php if($extraField->value != ''): ?>
				<?php if($extraField->type == 'header'): ?>
				<h2 class="itemTitle"><?php echo $extraField->name; ?></h2>
				<?php else: ?>
				<h2 class="itemTitle"><?php echo $extraField->value; ?></h2>
				<?php endif; ?>
			<?php endif; ?>
			<?php endforeach; ?>
	    <div class="clr"></div>
	  </div>
	  <?php endif; ?>

What do I need to change to get this working on that script as well?

Thanks

Ryan

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

  • Krikor Boghossian
  • Krikor Boghossian's Avatar
  • Offline
  • Platinum Member
More
11 years 4 weeks ago #117861 by Krikor Boghossian
Replied by Krikor Boghossian on topic Re: Special Characters in K2 Item Titles
Hello Ryan,

Glad to know it worked. I think you are missing the $this->item->title;

You have to repeat the same procedure for the user.php file. Be careful though because you may have to use $item-> instead of $this->item,. Also the if checks are different, the logic and method are the same.

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

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

  • olsen
  • olsen's Avatar
  • Offline
  • Elite Member
  • Joomla and K2 Freelancer
More
11 years 4 weeks ago - 11 years 4 weeks ago #117862 by olsen
Replied by olsen on topic Re: Special Characters in K2 Item Titles
On the user view (user.php) doesnt work beacuse extrafields are not rendered by K2 for this view (view='itemlist'&task='user').
You could made it work modifing a k2 core file models/item.php ( i dont not recommend this but it is a solution.)

Didn't solve your issues?? Why dont you consider hire me? Email me or contact me www.xevedigital.com for details

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


Powered by Kunena Forum