I need a region with a form to be hidden when the page loads and shown when the user is clicking on a button. I tried it with a dynamic action where I used "Show" an "Hide" but it is not working as planed. The region is displayed after loading the page.
Server-side conditions on a component are evaluated when the page is rendered. If the condition yields false, the component is not included in the rendered page so it is impossible to make it visible - simply because it is not in the DOM.
The way to show/hide a region is to:
Not set a server-side condition
use a dynamic action to show/hide
Related
When user open some Django view there is option to choose what data to load from postgres DB. After that click submit and process is started. But when data is fetched and in the same view pressed reload, then all process starts from begining. Fetched time is about ~10min (best solution to fetched once by opening view and after that just manupulate with data without fetced each reloading)
I want to load data once or by button. But how to implement that i don't understand.
The easier approach is to do this with two pages:
First page: User can choose to load the data
Second page: Loads the data and shows it
If you want to do this on the same page you normally put a div on your page where the data should be loaded and then you need to use Javascript / AJAX to load and update your current page (or a part of it) based on user input like a clicked button.
There are multiple ways to implement this. Here are some examples:
HTMX - Click to load
JQuery - load div on button click
Pure Javascript
I would recommend HTMX, because it allows you to do this without having to write any JavaScript and it works great together with Django templates.
I'm working on setting up a gateway form on a Sitecore 7.2 site using the Web Forms for Marketers module that installed and the fancybox plugin that the site has (the site is using fancybox version 1.3.4, and I cannot update this version or it may break other features on the site that are using this plugin).
This is how the form is supposed to work: The user clicks a link on a page and this opens a popup window with a form they must fill out before they can access a download.
So far, I have gotten things working so that, when a link is clicked on a page, the fancybox modal opens and displays the WFFM form.
Here is the jQuery that does this:
jQuery.noConflict();
(function($) {
$(document).ready(function() {
// Open the gateway form into a fancybox modal
//check to see if there is a gateway form link on the page
if ($(".protected-item").length > 0) {
//if so, then we want to target the click event
$('.protected-item').click(function(event) {
event.preventDefault();
//Get the value of the href of the link since this url will contain the page with the gateway form
var url = $('.protected-item').attr('href');
//open the page with the gateway form in the fancybox modal
$.fancybox({
'autoDimensions': true,
'height': 400,
'width': 400,
'scrolling': 'no',
'href': url,
'autoScale': true,
});
});
}
});
})(jQuery);
What I have done is created a generic page in Sitecore (I called in Gateway Form Test Page) and inserted the test gateway form onto it. Then, on the page I want to feature the gateway form on, I have linked some text ("click here") to that Gateway Form Test Page.
The problem is that, upon hitting the submit button for the WFFM form, the page sends me to the url where the form is located (i.e. domainname/OtherPages/GatewayFormTestPage.aspx) instead of just reloading the fancybox window and displaying the success message or an error message if not all fields are filled in.
I tried setting the type to 'iframe' for the fancybox modal, but all that did was render an empty popup (no content displayed in the fancybox-content block, either--I inspected the element in Chrome's dev tools).
Is there a way that I can wrap the WFFM form in an iframe so I can avoid going to another page when clicking "submit?" I want the user to stay within the popup modal at all times.
Thanks, and I know this is probably a convoluted process, and I wish I could choose a better solution but this is what I must work with.
I think that using iframe is not right approach for your task. It is better to use AJAX requests instead of iframe.
You should check "Is Ajax Mvc Form" on form item to reload only form without page postback. It will allow you get form update without full reloading page.
If you are using WebForms(not MVC) then you can wrap WFFM form into update panel.(not very good for performance and transparency)
And tip about usage WFFM: you should use it only in cases when fields/actions will be managed by marketers. You don't need to use it for all forms on site. Make sure that it is not your case.
We have developed a Sitecore site for a client who will primarily be using Page Editor. We've built page type layouts and then componentized everything else, including sub-layouts of content. This allows them the most flexibility when building pages.
So, an author goes to a page selects the main content area (Placeholder) of the page and inserts basic building block components that we've created. These include Rich Text box, page promos, etc. they can use these to build pretty rich pages with lengthy content.
All page components have the same Datasource Location, which is a "Page Components" folder that's setup as an item bucket.
This is all working well so far.
Now, I'm trying to make it so when a page is created a specific component is created, inserted into to our "Page Components" bucket and placed in a specific placeholder on the page.
I've been trying to build a Branch Template to accomplish this, but I don't see how to specify that the new component should be stored in our bucket location, instead of directly underneath the Page item. Also, how to make the component show up in the placeholder that I want on the page.
Is this possible? Thanks in advance for you help!
You will want to use a command template for this, since you are desiring to programmatically bypass Sitecore's standard layout configurations and branch template creation.
On your page template standard values, you will want to add the sublayout to the presentation details so you can hook the datasource in programmatically after creation.
The fundamental flow in the command will be as follows:
Create the desired page item
Create the desired component datasource in the bucket location
Search the layout definition of the created page item to find the appropriate sublayout to bind to.
Alter the datasource on the sublayout to bind to the datasource you created.
As #jammykam mentioned, there is a recent blog post now available.
I created a django form and want to display it in a light box after someone clicks a button on my html page. besides loading the form on the initial page load, i also wanted to call the view which displays the form with javascript. is there a way to only load the form template without reloading the entire webpage? I want to do this incase there are errors on the form so that I could just reload the lightbox with the form and error messages instead of the entire page.
Thanks!
Return just the HTML for the form from a separate view, then call the view via XHR. Once you've received the HTML, just replace what is already in the appropriate div.
I am currently having an issue when using the raw_id_field within admin.py in my Django project.
My site's admin area has a number of image upload fields for various different model pages which are all ForeignKey fields to an Image model where all images for the site are stored.
As the site will eventually be dealing with a large quantity of images (100s, maybe 1000s) the default select box would be unusable.
I created various admin.ModelAdmin classes e.g
class InfoSlideAdmin(admin.ModelAdmin):
raw_id_fields=('image',)
These change the image selector within my Edit pages from a Select Box to a Raw ID Field.
However when I select a different image using this control although the ID of the new image is shown the title from the previous image still displays.
Any ideas?
The title is refreshed via Javascript when you close the pop-up window. It's possible that you have some sort of cross-domain issue which is preventing the JS from running - this does sometimes occur when you're running via the development server on eg port 8080.
Have a look at what the console in Firebug is showing you (you are using Firebug to debug Javascript problems, aren't you?).
I do use firebug to debug issues such as this yes. However I normally use the "Net" tab and track which files are being called by the page as it loads. However you can only use the Net tab after a page refresh and this does not occur when using the raw_id control.