Keyword

Overriding view code

  • Bruce H
  • Bruce H's Avatar Topic Author
  • Offline
  • New Member
More
13 years 3 months ago #97544 by Bruce H
Overriding view code was created by Bruce H
Hello,

I am new to K2 and only somewhat acquainted with Joomla in general, but need to make some improvements for a client of mine  I've figured out how to override the templates with no problem and have made successful changes to the item layout.

 

What I'm trying to do now, is I need to add one <link> tag to the <head> section of items.  I've tried to do it from my item.php override, but I'm guessing it's too late at that point to add head content.  I need information from the K2 item which is why I'm trying to do this in K2. I can see that I could do it very easily in:

components/com_k2/views/item/view.html.php

but being a good developer, I would rather not modify the code directly.  So my question is if there is a way to override the view code file so that I can make this change in my own copy and have it picked up by K2?

 

Thanks for any help on this.

 

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

More
13 years 3 months ago #97545 by william white
Replied by william white on topic Overriding view code
This may be a start

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

  • Bruce H
  • Bruce H's Avatar Topic Author
  • Offline
  • New Member
More
13 years 3 months ago #97546 by Bruce H
Replied by Bruce H on topic Overriding view code
Thanks for the reply William.  I have done the template override described in the article you pointed me to, but as I mentioned in my original post, I need to add head content and it seems that by the time the item.php is being processed, it's too late to add head content.

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

More
13 years 3 months ago #97547 by Jiliko.net
Replied by Jiliko.net on topic Overriding view code
Hey,

 

You can work with the document header when you're in the item.php template file :

 

$document = & JFactory::getDocument();

 

//To add a css file :

$document->addStyleSheet(JURI::base().'mycss.css');



//To add a script file :

$document->addScript(JURI::base().'myscript.js');

 

//To modify the Document Header :

$tabHead = $document->getHeadData();

$tabHead[] = ...; //code for new link

$document->setHeadData($tabHead);

 

Make a print_r($tabHead); command to check the content of your document header.

 

JDocument Joomla API docuementation( 1.5)

api.joomla.org/Joomla-Framework/Document/JDocument.html

 

Regards,

 

Olivier

 

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

  • Bruce H
  • Bruce H's Avatar Topic Author
  • Offline
  • New Member
More
13 years 3 months ago #97548 by Bruce H
Replied by Bruce H on topic Overriding view code
Hi Olivier,

 

Ok, I will try again.  Maybe I was doing something wrong.  I was trying to call addHeadLink by doing pretty much what you describe here and it wasn't working.  But I wouldn't be surprised if it was me.

 

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


Powered by Kunena Forum