Keyword

Edit K2 CSS - Category and Item

  • Michael Brown
  • Michael Brown's Avatar Topic Author
  • Offline
  • New Member
More
8 years 10 months ago #148998 by Michael Brown
Edit K2 CSS - Category and Item was created by Michael Brown
Hi,

I'm new to Joomla and K2, but in the 7 days working with it I've done more than a few template overrides -- around 7. All of them easy..until K2 for some reason. It doesn't help that there are at least 5 different versions of how to do this. Very confusing when it doesn't work as planned.

Here it what I have done in the aim of modifying the category layout and single item display (displayed when clicking on the title)

1) made a copy of components/k2/templates/default
2) moved the copied /default folder and files to templates/my_template/html/com_k2 where I renamed "default" folder to "news". Now I have a listing of a folder "News" (a category of K2) with sub files under "news" containing the 10 files copied from components/k2/templates/default in addition I added a css file news.css

The "news" template shows up in K2 and I can assign the category to it, but I do not see the news.css file loaded on the page. Modifying a .php file - such as category.php within the /my_template/com_k2/news does not reflect changes on K2.

News.css has the following to test if css is working:

div.itemHeader h2.itemTitle {
font-family:Georgia, "Times New Roman", Times, serif;
font-size:36px;
font-weight:normal;
line-height:110%;
padding:10px 0 4px 0;
margin:0; color: gold;
}


Any guidance would be much appreciated. I've spent hours on this :/

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

  • Michael Brown
  • Michael Brown's Avatar Topic Author
  • Offline
  • New Member
More
8 years 10 months ago #149023 by Michael Brown
Replied by Michael Brown on topic Edit K2 CSS - Category and Item
I resolved this with sheer trial and error... a painful way to go about things. Maybe if I would have paid more attention in Spanish class, that tutorial on template overrides written in Spanish in your docs area would have been helpful... I can only speculate.

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

More
8 years 10 months ago #149035 by Lefteris
Replied by Lefteris on topic Edit K2 CSS - Category and Item
Hi,

I am glad that you resolved that. Let us know if you need anything else.

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

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

  • Michael Brown
  • Michael Brown's Avatar Topic Author
  • Offline
  • New Member
More
8 years 10 months ago - 8 years 10 months ago #149039 by Michael Brown
Replied by Michael Brown on topic Edit K2 CSS - Category and Item
Thanks Lefteris,

I've been able to setup a custom blog in just a day and a half. I'm quite happy with K2 so thanks for the work. One final detail I'm missing.

I'm attempting to limit the intro text. I have it set to 75 words in the params and the option to display the full text disabled, but alas the full blog post shows. Is there another setting I'm missing somewhere? Of course the goal is to have all of the blog posts the same height by setting a limit to the words displayed in the category view.

Thanks!
Last edit: 8 years 10 months ago by Michael Brown.

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

  • Michael Brown
  • Michael Brown's Avatar Topic Author
  • Offline
  • New Member
More
8 years 10 months ago #149042 by Michael Brown
Replied by Michael Brown on topic Edit K2 CSS - Category and Item
Scratch that... you can limit it with PHP since, unless I'm blind the limit intro doesn't function on K2 Category view..or any view? Anyways, the below code does the job.
if(!function_exists('cut_string')){
	function cut_string($title, $max)
	{
	    if($title!=''){
	    if(is_array($title)) list($string, $match_to) = $title;
	    else { $string = $title; $match_to = $title{0}; }
	 
	    $match_start = stristr($string, $match_to);
	    $match_compute = strlen($string) - strlen($match_start);
	 
	    if (strlen($string) > $max)
	    {
	        if ($match_compute < ($max - strlen($match_to)))
	        {
	            $pre_string = substr($string, 0, $max);
	            $pos_end = strrpos($pre_string, " ");
	            if($pos_end === false) $string = $pre_string."...";
	            else $string = substr($pre_string, 0, $pos_end)."...";
	        }
	        else if ($match_compute > (strlen($string) - ($max - strlen($match_to))))
	        {
	            $pre_string = substr($string, (strlen($string) - ($max - strlen($match_to))));
	            $pos_start = strpos($pre_string, " ");
	            $string = "...".substr($pre_string, $pos_start);
	            if($pos_start === false) $string = "...".$pre_string;
	            else $string = "...".substr($pre_string, $pos_start);
	        }
	        else
	        {
	            $pre_string = substr($string, ($match_compute - round(($max / 3))), $max);
	            $pos_start = strpos($pre_string, " "); $pos_end = strrpos($pre_string, " ");
	            $string = "...".substr($pre_string, $pos_start, $pos_end)."...";
	            if($pos_start === false && $pos_end === false) $string = "...".$pre_string."...";
	            else $string = "...".substr($pre_string, $pos_start, $pos_end)."...";
	        }
	 
	        $match_start = stristr($string, $match_to);
	        $match_compute = strlen($string) - strlen($match_start);
	    }
	 
	    return $string;
	    }else{
	        return $string ='';
	    }
	}
}
		<?php echo cut_string($this->item->introtext,460); ?>

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

More
8 years 10 months ago #149057 by Lefteris
Replied by Lefteris on topic Edit K2 CSS - Category and Item
Introtext word limit should work but it's counting words, not letters. This means that you will not get equal height blocks using this. K2 includes a javascript utility that will help you add equal height blocks. Just add the class "k2EqualHeights" to the blocks you wish to have equal heights and K2 will handle the rest.

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

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


Powered by Kunena Forum