Keyword

K2 Add new item window resize

More
13 years 11 months ago #87297 by william white
Replied by william white on topic K2 Add new item window resize
If you use an override this may help

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

More
13 years 11 months ago #87298 by Hanny
Replied by Hanny on topic K2 Add new item window resize
I have successfully done it.

If you add the following line of code to your item.php file it will close the window after the article is saved (the file is found in your_site\components\com_k2\views\item\tmpl\form.php)

 

Add this code at or around line 36 - after the line 'submitform( pressbutton );'

parent.$('sbox-window').close();

 

So it should now look like:

<?php endif; ?>submitform( pressbutton );parent.$('sbox-window').close();

 

I'm currently working on the javascript needed to refresh the page once the window closes so you'll see the 'Item Saved' text at the top of the screen.

 

If you do not change line 254 the article will be 'locked' on the backend - if you want the article to save without being locked you can change the text on line 254 to read:

<a class="toolbar" href="#" onclick="javascript: submitbutton('save'); return true;">

If you do this - the 'your item has been saved' text will not show - I'm working on resolving this

 

I hope this helps other people who were running into the same issue as me.

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

More
13 years 11 months ago #87299 by Peter Clarke
Replied by Peter Clarke on topic K2 Add new item window resize
Thanks Hanny! Looking forward to the rest of your solution.

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

More
13 years 11 months ago #87300 by Hanny
Replied by Hanny on topic K2 Add new item window resize
Well, I'm at a stumbling block.

From my reading it looks as if we don't even need to include

parent.$('sbox-window').close();


to get the window to close.

All that needs to be done is the following:

 

window.parent.location.reload();


 

That will reload the page, and since the new item is opened in an Iframe, when the page is reloaded the iframe will go away automatically.

 

BUT, it needs to be added to the postback from the javascript (which exists somewhere, that's why 'Add Item' changes to 'Edit Item')

I'm just too new to javascript to know where to look or where to put it in order for it to work.

 

Wish the developers would chime in on this considering it's been such a huge stumbling block for so many...

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

More
13 years 10 months ago #87301 by Hanny
Replied by Hanny on topic K2 Add new item window resize
Okay, here's how it's done.

If you have users creating articles from the front end and you want the 'save' button to close the model box window that pops up when they add or edit an article - just follow the steps below to achieve this:

 

*Note: there are a few other fixes that work to close the box, but not refresh the page - this does both.

 

The key is passing an extra parameter through the URL that gets created when the user clicks "Save", then we just check to see if that parameter (which I will call 'step') exists - if it does, we refresh the page.

 

Lets follow along, first we must add this parameter to the URL created -

Open the item.php file located at:

Yoursite->administrator->components->com_k2->models->item.php

 

On or around line 646 - you will see some text that resembles:

case 'save':            default:                $msg = JText::_('Item Saved');                if ($front)                $link = 'index.php?option=com_k2&view=item&task=edit&cid='.$row->id.'&tmpl=component';                else                $link = 'index.php?option=com_k2&view=items';                break;


So what we need to do is add our parameter to that URL so it will look like this (remember I called the parameter 'step', and will be setting it =1) - the code will now look like this:

 

                if ($front)                $link = 'index.php?option=com_k2&view=item&task=edit&cid='.$row->id.'&step=1&tmpl=component';


 

Now when the user clicks 'save' the parameter 'step' is getting passed along, and when the form reloads to show the user their information they had entered, step=1!

 

So then we have to add the php to check for that - that's simple enough:

Open the form.php file located at:

Yoursite->components->com_k2->views->item->tmpl->form.php

 

In there you can see where the form actually begins (on or around line 249), what we want to do is just add a little bit of php that checks to see if our 'step' parameter is equal to 1.  If it is - we'll refresh the parent page using some javascript, that will automatically close the model box and cause the 'item saved' text to display to the user letting them know what happened.

The existing code looks like :

<form action="index.php" enctype="multipart/form-data" method="post" name="adminForm" id="adminForm">    <div class="k2Frontend">                    <table class="toolbar" cellpadding="2" cellspacing="4">


 

When finished it will look like this:

 

<form action="index.php" enctype="multipart/form-data" method="post" name="adminForm" id="adminForm">    <div class="k2Frontend">        <?php if (JRequest::getInt('step')=='1') { ?>        <script language="javascript">        window.parent.location.reload();        </script>        <?php        } ?>                    <table class="toolbar" cellpadding="2" cellspacing="4">


 

That checks to see if 'step' is =1.  If it is - it runs javascript to refresh the parent window - closing the box and refreshing the page automatically.

 

This ensures the easiest possible thing for the user (i.e. they don't have to click 'back' and 'refresh' which is extremely counter-intuitive) and gives the front end user a back-end experience.

 

I hope this helps people - it took me a LOT of chasing things in the wrong direction before I thought of this solution.

I'm pretty saddened the developers never helped with something that's affected so many people, but oh well - problem was solved!

 

Keep on, keepin' on!

 

 

 

 

 

 

 

 

 

 

 

 

 

Okay, here's how it's done.

If you have users creating articles from the front end and you want the 'save' button to close the model
box window that pops up when they add or edit an article - just follow
the steps below to achieve this:

 

*Note: there are a few other fixes that work to close the box, but not refresh the page - this does both.

 

The key is passing an extra parameter through the URL that gets created
when the user clicks "Save", then we just check to see if that parameter
(which I will call 'step') exists - if it does, we refresh the page.

 

Lets follow along, first we must add this parameter to the URL created -

Open the item.php file located at:

Yoursite->administrator->components->com_k2->models->item.php

 

On or around line 646 - you will see some text that resembles:

case 'save':             default:
                $msg = JText::_('Item Saved');
                if ($front)
                $link =
'index.php?option=com_k2&view=item&task=edit&cid='.$row->id.'&step=1&tmpl=component';
                else
                $link = 'index.php?option=com_k2&view=items';
                break;

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

More
13 years 10 months ago #87302 by juju
Replied by juju on topic K2 Add new item window resize
Thanks a lot men ! It works like a charm :)

But I still don't like the pop-up box, I prefer a lot the Joomla basic window, integrate in the website, for adding article...

 

Has anyone tried to do that ? : remplace the pop-up box system and have a display like in backend, I mean with window integrate in the website ?

 

Thanks a lot ;)

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

More
13 years 10 months ago #87303 by Andy Connell
Replied by Andy Connell on topic K2 Add new item window resize
Yes - Email me & I'll send you instructions! This email address is being protected from spambots. You need JavaScript enabled to view it.

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

More
13 years 10 months ago #87304 by juju
Replied by juju on topic K2 Add new item window resize
I have a big problem, I don't know if it's due to the modification for the button save, but for each article I add, they are lock in back end. I had to unlock them with "Tools"->General Validation in backend.

 

For example, the user "Juju" add 4 articles, they are all locked. And when "Juju" logout, all article unlock itself.

 

Any idea ? It's really weird Oo ...

 

Thanks ;)

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

More
13 years 10 months ago #87305 by Andy Connell
Replied by Andy Connell on topic K2 Add new item window resize
Ive seen the answer to that in one of these discussions, maybe on the asksimon site - cant remember. I find it I'll update here.

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

More
13 years 10 months ago #87306 by Hanny
Replied by Hanny on topic K2 Add new item window resize
I thought it was a safety feature - so that if someone is logged in, their articles are 'locked' so they can't be edited/worked on while they may be working with them.

At least that was my understanding of what I saw.

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

More
13 years 10 months ago #87307 by Odin Mayland
Replied by Odin Mayland on topic K2 Add new item window resize
it is true that if another user is editing the item then it will be locked to other users.

 

If you log everyone out and you still see lock icons on the items then there is a problem.
Hanny said:

I thought it was a safety feature - so that if someone is logged in, their articles are 'locked' so they can't be edited/worked on while they may be working with them.

At least that was my understanding of what I saw.

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

More
13 years 10 months ago #87308 by juju
Replied by juju on topic K2 Add new item window resize
Yes, but I never notice that before.

 

I thought the security is only when the user edit an article, nobody can edit THIS article in the same time.

 

But here, each time a user is connected, all his article are locked in back end Oo

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

More
13 years 10 months ago #87309 by juju
Replied by juju on topic K2 Add new item window resize
I just test with a fresh installation, if I add an item, even if I'm only an author (item unpublished), it is not blocked in back-end...

 

So what I could change that caused that ? The last thing I do is modify the button save to redirect with the code here : community.getk2.org/forum/topics/k2-add-new-item-window-resize?id=3536014%3ATopic%3A73456&page=13#comments

 

I don't understand, someone had an idea ?

 

Thanks ;)

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

More
13 years 10 months ago #87310 by juju
Replied by juju on topic K2 Add new item window resize
So, I retry again without the modification in the file form.php, and it works well again :)

 

So the problem really come from the modification :

 

<?php if (JRequest::getInt('step')=='1') { ?>        <script language="javascript">        window.parent.location.reload();        </script>        <?php        } ?>

 

 

Can anybody confirm the problem ?

 

Thanks for your help ;)

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

More
13 years 10 months ago #87311 by Hanny
Replied by Hanny on topic K2 Add new item window resize
I'm surprised to hear it causes that problem.

All that bit of code does is say "If there is an integer that is = 1, refresh the page" it has nothing to do with the locking and/or unlocking of the pages.

 

Also, that code is ran after the database stuff has executed and the article is saved, so I really don't understand how that causes the issue - but if it does, it does.  I'll have to look into it a bit myself - although I can't promise anything because for me it's not a big issue - I don't allow editing of other peoples articles anyway, so if they're 'locked' when that user is logged in I am okay with it. 

 

I'll have to dig around, see what I can find.

 

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

More
13 years 10 months ago #87312 by juju
Replied by juju on topic K2 Add new item window resize
I know, but it's not so weird :

 

In fact, if you quit the pop-up window with the little cross in top right corner, it's not the same than simply refresh the window.

 

Clicking on the cross or on cancel button do something.

 

When you refresh the window, the popup disappear,but it's not the same than clicking on the cross or cancel button ;)

 

Did you try to see the problem ? It's simple to trigger the problem :

 

Open a page, Log in backend, with admin account.

Open an other page, Log in front end with author account.

Click on "Add an article" on front end, and click on save, your modification quit the popup window and refresh the page behind.

Go in backend, go see your articles list, the last added is locked...

 

 

 

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

More
13 years 10 months ago #87313 by Hanny
Replied by Hanny on topic K2 Add new item window resize
Yea, I understand now.

I'll have to figure out what the close window button is doing (and/or the cancel button) and try to add that code into the if statement. 

That should essentially cure the issue (in theory anyway).  I'll see what I can hack up.

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

More
13 years 10 months ago #87314 by juju
Replied by juju on topic K2 Add new item window resize
Yes, that's what I try to do this morning, but I failed...

But I did only few tests, so maybe you'll make it, I hope so :)

 

Thanks again ;)

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

  • Jasper Newton
  • Jasper Newton's Avatar Topic Author
  • Offline
  • Senior Member
More
13 years 10 months ago #87315 by Jasper Newton
Replied by Jasper Newton on topic K2 Add new item window resize
I have to say, almost 7 months after I started this thread, and K2 told me they were going to do nothing about it because I had called them names, and it "is not a bug, just an inconvenience" and people like William White responding again with "use an override", I wonder if now K2 will take a look at this problem? Que inane answers that don't address the problem, like "use an override".

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

More
13 years 10 months ago #87316 by Hanny
Replied by Hanny on topic K2 Add new item window resize
That's the reason I want to fix some of these issues.

So the users who do use this, can stop being inconvenienced.  Isn't that the point of a developer?  To work to remove things that make the user experience inconvenient?  If it wasn't for a few features K2 has that I couldn't find elsewhere, I would be using a different component for sure.  Heck, might have been easier to integrate features the others were lacking, than it is to try and fix this 'inconvenience'.

 

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


Powered by Kunena Forum