Friday, 18 February 2011 14:10

How to alter settings for front end editing screen in K2

Written by 
Rate this item
(5 votes)

This quick article has been taken from many comments and threads on the K2 community pages and forum, hopefully this will be obsolete when K2 2.5 comes out with these bugs fixed ??

These fixes are for the problem with the front end "add an article" pop up, popping up to big for users with lower res screens. 

The second fix is for the save button, that when clicked, does save the file, but doesn't close down the screen. I have both of these working with K2 2.4.1

These are bothhacks and you should remember that when you upgarde to a newer version of K2 these will/may be overwritten


First the SAVE BUTTON

go to components/com_k2/views/item/tmpl/form.php

After string 35: "submitform( pressbutton );"
You can add:
36: parent.$('sbox-window').close(); /* To close modalbox */
37: alert( ' Send ! ' ); /* To view a message */

 


 

Second - resizing the pop up screen

You will need to modify the following K2 core files:

components/com_k2/templates/user.php
components/com_k2/templates/default/category.php
components/com_k2/templates/default/item.php 

If you use custom K2 templates, then there is a little more you can do:
templates/YOURJOOMLATEMPLATE/html/com_k2/templates/user.php
templates/YOURJOOMLATEMPLATE/html/com_k2/templates/YOURK2THEME/category.php
templates/YOURJOOMLATEMPLATE/html/com_k2/templates/YOURK2THEME/item.php

You need to replace the "so famous" rel="{handler:'iframe',size:{x:990,y:650}}"

1) To alter the size of the window in the K2 Login module, find the Userblock.php file, found by; modules/mod_k2_login/tmpl/userblock.php. On or around line 35 (in mine, may vary in yours), find the line;

rel="{handler:'iframe',size:{x:990,y:650}}"

And replace it with this:

rel="{handler:'iframe',size:{x:window.getSize().scrollSize.x-80, y: window.getSize().size.y-80}, onShow:$('sbox-window').setStyles({'padding': 0})}"

In a few words, what this code does is resize the popup window (appears when you click "Add new item" from K2 Login module), conform to your window (not screen) resolution. Then you can see whole the window in a wide view. Well that's what I can see from my laptop. (1280x800)

Note: Maybe you will see many of this rel="{handler:'iframe',size:{x:990,y:650}}" well, just replace all of them to get the problem fixed.

If you want to do this with the component for a better font-end edit just follow these steps:

2)To alter the size of the window in the category add item link, again find the file "Category.php, item.php and User.php"
These can be found by; component/com_k2/templates/default/(category.php/item.php/user.php)
Again find the exact same line as before
rel="{handler:'iframe',size:{x:990,y:650}}" and replace it.

3) To alter the size of the modal window for the "Edit item" link, find the category_item.php file; found by: component/com_k2/templates/default/category_item.php
Do exactly the same as above.

 


 

Bonus - Remove the pop up all together and display in a normal window

You can disable the lightbox by removing the class and the rel.

Before:

class="modal" rel="{handler:'iframe',size:{x:window.getSize().scrollSize.x-80, y: window.getSize().size.y-80}, onShow:$('sbox-window').setStyles({'padding': 0})}" h r e f=" < ?php echo $user->profile->addLink; ?> " > < ?php echo JText::_('Add new item'); ? >< /a>

After:

h r e f="< ? php echo $user->profile->addLink; ?> " >

This way you will get a "normal" link to open in a same window or in a new tab.
Just remember remove the class="modal" because if you don't it will display a worst lightbox

Read 2690 times Last modified on Friday, 18 February 2011 14:36

5 comments

  • Comment Link batuhan Thursday, 09 February 2012 16:11 posted by batuhan

    Super ! thank you

  • Comment Link yogie Saturday, 21 January 2012 20:00 posted by yogie

    now, if only this can be done for K2 ver 2.5.4

  • Comment Link dare mike Thursday, 21 July 2011 04:08 posted by dare mike

    Wow, great tutorial, now I have more confidence of using K2 for my web projects. Would surely like to come back here for more tuts. Great workman

  • Comment Link Fernando Thursday, 26 May 2011 19:42 posted by Fernando

    You saved my life!!! TKS

  • Comment Link LH Wednesday, 13 April 2011 02:16 posted by LH

    Thanks man, very useful!

Leave a comment

Who's Online

We have 4 guests online