- Posts: 3722
COMMUNITY FORUM
K2 Add new item window resize
- william white
- Offline
- Platinum Member
Less
More
13 years 9 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.
- Hanny
- Offline
- Senior Member
Less
More
- Posts: 48
13 years 9 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.
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.
- Peter Clarke
- Offline
- New Member
Less
More
- Posts: 4
13 years 9 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.
- Hanny
- Offline
- Senior Member
Less
More
- Posts: 48
13 years 9 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...
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.
- Hanny
- Offline
- Senior Member
Less
More
- Posts: 48
13 years 8 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;
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.
- juju
- Offline
- Premium Member
Less
More
- Posts: 119
13 years 8 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 ;)
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.
- Andy Connell
- Offline
- Senior Member
Less
More
- Posts: 54
13 years 8 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.
- juju
- Offline
- Premium Member
Less
More
- Posts: 119
13 years 8 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 ;)
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.
- Andy Connell
- Offline
- Senior Member
Less
More
- Posts: 54
13 years 8 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.
- Hanny
- Offline
- Senior Member
Less
More
- Posts: 48
13 years 8 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.
At least that was my understanding of what I saw.
Please Log in or Create an account to join the conversation.