I have a content type with image field and need to replace it with another image already uploaded on server. Best would be to do it with AJAX call to avoid page reload.
Is it just a matter of replacing "fid" in node's field value?
I've been messing with the ajax framework lately myself. There are probably better approaches, but the difficulty is in placing multiple ajax events on a single form element and file fields already have one on them.
One option could be to implement hook_ajax_render_alter, and add to/modify/replace what file_ajax_upload() provided in the $commands array as needed..
Related
I have a Django application which takes the lat/lon from a user's coordinates via HTML5 geolocation and places these into form fields via jQuery. Markers are then placed on a map using these coordinates. This works very well.
The problem: I want to hide these forms so they're invisible to the user, but these still need to be "on the page" so they can receive the information. So excluding these via the Django forms file won't be acceptable.
I tried one method which hid the form field but left the form label. I'd like to hide the entire row from the user and remove the space where the form field exists while it still remains in the background to receive the info.
Is this possible? Not sure if it requires a CSS trick or a something built-in to Django.
Any help or insight appreciated.
Give your forms an ID and in CSS set display: none for these IDs. Alternatively, use a common class instead of separate IDs.
I'm creating a short-code generator for the WordPress Add/Edit Post/Page screen.
I want to make sure that there does not exist more than one short-code in the same post/page. So I added an onclick function for the button so that whether there already exist a short-code, could be checked.
How do I go on doing this?
I searched around the TinyMCE API and the closest I got was the tinymce.Formatter.match method. But there's no example on this page. I don't really think that this has anything to do with the content search anyway.
Another way would be to simply use the getContent method and run javascript code against it. But I guess this wouldn't be the best option if there's something built-in for this already.
I do not know exactly what you mean by the term "short-code".
But i guess it is a string you can find using getContent-Method.
There are several other ways to search the editor content.
Since tinymce editor is rendered inside an iframe and is indeed real html code you can use all regular DOM-Methods of your browser. There are even some additional DOM-Methods provided in tiny_mce/classes/dom/DOMUtils.js.
I have a column in my database that stores images that are links, when i populate them in a gridview on my asp.net page I want it to display the image as a link but when i did it i just get the text below.
<img src="http://www.url.com/url/url/url/url.jpg">
My goal is to have a list of the images and when a user clicks the image they will go to another page. This is a start of my page, and i was attempting to use a gridview but now I am not sure what to do
Don't save markup
Instead just save a URL. In your case two of them since one points to *.html and the other to *.jpg. Or just without extensions if they're always the same except for the extensions. This way you can easily change your markup later and still use the same data from the DB.
But apart from this fact of not saving non-data in DB you could at least provide some relevant code you're using. We'd much easier tell you where you're doing it wrong.
Using GridView
The problem you're having are column templates. Check this link out and see how you can customize the display of a particular column in a GridView. Essentially you will have to provide your own template and do whatever you please with your DB data.
I'm using Views in Drupal to show node teasers. I would like now to show the complete node on the left side of my page, nearby the Views, and update it when the user click on a different teaser (better using AJAX).
what's the best method to implement it. I was considering to use a lightbox, but it a bit complex (a lot of complications... such as parsing the content with javascript again.. etc).
See screenshot: http://dl.dropbox.com/u/72686/viewsAndNode.png
Thanks
A quick and dirty approach would be to use an iframe to hold the node content. Users would then be able to switch between nodes without reloading the page, which is I assume your goal. I don't think there is away to achieve what you are trying to do with views out of the box. Have you looked into using panels?
Here's what might be a clean way to do it, of course in drupal there's always many ways to accomplish things.
Providing the content for the ajax call
Install the services module
Setup a service that provides your node as you want it to be displayed
Create the placeholder for your content
Install the Panels Module
Create a empty fixed width panel to contain the node you want to load
Load the view into an adjacent panel
In your controlling view
Add a PHP view header and use (drupal_add_js('script.js')) to add a custom js file to the page. or add this to a custom module, or even your theme.
Re-Write your view node links to help put the js events together
Setup your javascript events
Use add_js to add a custom javascript js file to the page
In the custom js add an event to the view links that will poll the services module and load the node into the placeholder panel
I've solved using the lightbox, and just removing the html code I don't need from the node template with php if the parameter "lightbox=true" is passed with the link.
I've used CCK to create a 'Travel Offer' content-type which basically just lists the details for a travel package.
My question is how to have a button or link on each node (when the user views it) that will link to a url that includes the title of the current node (eg: example.com/requestQuote/Title_Of_This_Node).
I haven't implemented my system yet so I am free to change the content-type to include a button field or something like that...
The easiest way to accomplish this would be by adding a node-your_content_type_name.tpl.php file into your theme folder. (If you haven't done this before, all you need to do is create a duplicate of node.tpl.php and rename the copy to node-your_content_type_name.tpl.php)
The '$title' variable is available within the node template, so it should be easy to craft a little bit of PHP to print out the appropriate link target.
Edit:
Now, if you want to get a little bit fancier, you could build the link to reference the unaliased node page ('example.com/requestQuote/node/11569' or whatever) and feed it through Drupal's handy l() function to build the hyperlink.
The advantage here is that you won't need to worry about the link changing if the title changes, even though l() will automatically update the actual hyperlink that's displayed to the user.
This will probably make the custom coding on your 'example.com/requestQuote' page a lot easier too, since you can work directly with the node ids and don't need to parse titles.