Can I have an upload files feature in an Asset Builder that creates News Items


(Ryan Archer) #1

Hi,

 

Looking for a way of allowing a user to upload images when they are using the asset builder to create news items?

I looked in the available keywords for creating a News Item and I can't see any option to allow file uploads in the form.

 

How could this be achieved?


(Nic Hubbard) #2

Sure, you could use my MatrixUpload2 plugin: https://github.com/nnhubbard/matrixupload2

 

Makes it super simple to have drag n drop file uploads, even on the Created screen of an asset builder. :)


(Ryan Archer) #3

Hi Nic,

 

Fantastic plugin but I'm really not sure how to incorporate it. I want one asset builder to create news items and upload an image all in the same form. By following the directions in your plugin it would appear that I have to set up another dynamic location and then I set up two different Asset Types to Create - so then I have a form which toggles between an interface for uploading images, and then an interface for creating the News Item. Is there a way to consolidate both of these into one form?

 

I just feel that it will be so easy for our users to forget to upload the image when creating the News Item.


(Nic Hubbard) #4

Hi Nic,

 

Fantastic plugin but I'm really not sure how to incorporate it. I want one asset builder to create news items and upload an image all in the same form. By following the directions in your plugin it would appear that I have to set up another dynamic location and then I set up two different Asset Types to Create - so then I have a form which toggles between an interface for uploading images, and then an interface for creating the News Item. Is there a way to consolidate both of these into one form?

 

 

In my opinion the easiest way is to place the plugin on the Created screen. If you want to do everything on one page, you are going to have to use ajax to submit the first asset builder and return the created asset ID that will be passed into the plugin. Or you could use the JS API for complete flexibility. 


(Ryan Archer) #5

So are you suggesting that the user creates the post first and then the next screen that shows (the 'created' screen) will then urge them to upload any associated images?

 

Also, how does one select the default location for all images to go to? I have setup dynamic locations to place the news item beneath a specific folder category of the user's choice but I also want to 'hard set' a location for all the uploaded images. I am trying to do it with Dynamic Create Locations AND/OR Create Location Rules but it's not working out. I want the images NOT to be created in the same directory as the News Items.


(Nic Hubbard) #6

So are you suggesting that the user creates the post first and then the next screen that shows (the 'created' screen) will then urge them to upload any associated images?

 

Also, how does one select the default location for all images to go to? I have setup dynamic locations to place the news item beneath a specific folder category of the user's choice but I also want to 'hard set' a location for all the uploaded images. I am trying to do it with Dynamic Create Locations AND/OR Create Location Rules but it's not working out. I want the images NOT to be created in the same directory as the News Items.

 

Yes, doing it on the second screen.

 

Sadly, you cannot have an either/or situation with create locations. It will link them in both locations. However you could use a trigger to remove the unwanted link.


(Ryan Archer) #7

I think I am going to have to make a separate asset builder for the images then unfortunately because of three reasons:

 

1) On the second 'created' screen, none of the image upload keyword replacements are actually working

2) We really want to be able to control the location of where the images get uploaded into

3) Can't seem to upload the image first and then create the post (as the system does not know where to put the image as that is controlled by the dynamic news item location

 

I can only see the option of having two different content types to create as an OR option and not a AND option.

 

Just another thing, I uploaded your plugin files and called on them within my design file. But there is an issue. When I call on the javascript using the 'ready' command within the "created" bodycopy - it just displays the javascript code, and I am using raw HTML too.


(Nic Hubbard) #8

Just another thing, I uploaded your plugin files and called on them within my design file. But there is an issue. When I call on the javascript using the 'ready' command within the "created" bodycopy - it just displays the javascript code, and I am using raw HTML too.

 

Did you make sure to put the js in script tags?


(Nic Hubbard) #9

I think I am going to have to make a separate asset builder for the images then unfortunately because of three reasons:

 

1) On the second 'created' screen, none of the image upload keyword replacements are actually working

2) We really want to be able to control the location of where the images get uploaded into

3) Can't seem to upload the image first and then create the post (as the system does not know where to put the image as that is controlled by the dynamic news item location

 

I can only see the option of having two different content types to create as an OR option and not a AND option.

 

So many variables here to even try to imagine what is going wrong. This is one of those times that I wish I could see your implementation. Could you make the page live with a long URL and email that to me?


(Douglas (@finnatic at @waikato)) #10

Looking for a way of allowing a user to upload images when they are using the asset builder to create news items?

I looked in the available keywords for creating a News Item and I can't see any option to allow file uploads in the form.

 

Do you have a firm requirement to create the assets as "news item" assets?  How much non image information is there?

 

An alternative which may work for you is to have an asset builder which creates images, and stores all the other information for the news item as metadata fields.


(Ryan Archer) #11

 

Do you have a firm requirement to create the assets as "news item" assets?  How much non image information is there?

 

An alternative which may work for you is to have an asset builder which creates images, and stores all the other information for the news item as metadata fields.

 

I'm making a blog so the news items are non negotiable.

I've just linked the image asset builder to come in as a popup window over the top of the news item asset builder. So first thing is user uploads the image(s) using the popup window and then create the news item and use the WYSIWIG to find the uploaded image and insert it into the News Item Body field.


(Ryan Archer) #12

 

Did you make sure to put the js in script tags?

 

@Nic, 

 

I got your matrixuploader plugin working (somewhat).

Issue is I can't seem to get some of the options working, namely:

  • changing layout to list
  • no commit/upload button

Can you please provide a more detailed example? Your Github page only really shows a few options.

 

I'm trying this out and get no luck:

<script>
$( document ).ready(function() {

$(‘form[id*=“asset_builder”]’).matrixUpload({
    progress: function(progress) {
        console.log(progress);  
    },
    filesSelected: function(files) {
        console.log(files.length);  
    }
layoutType: {ZSSMatrixLayoutList}
});

});
</script>

It actually breaks and goes back to the original Squiz Matrix upload asset screen.

 

When I do get it working with just the default call I get the screen that is attached.

 

UPDATE: with just the default implementation "$('form[id*="asset_builder"]').matrixUpload();" it seems to get broken when an image is uploaded.

The progress bar appears and is stuck on zero and nothing happens. I assume a insert/commit button appears once at least one image has been inserted/uploaded...?

 

squiz-uploader.jpg (34.4 KB)
squiz-uploader-pic.jpg (41.5 KB)


(Nic Hubbard) #13

UPDATE: with just the default implementation "$('form[id*="asset_builder"]').matrixUpload();" it seems to get broken when an image is uploaded.

The progress bar appears and is stuck on zero and nothing happens. I assume a insert/commit button appears once at least one image has been inserted/uploaded...?

 

That is just an example jQuery selector. Your implementation might require a more specific ID based selector to better target the asset builder form element.


(Ryan Archer) #14

and you just lost me...  :blink:

I just looked in firebug and can see that the ID is page_asset_builder_287482

 

I have changed the code but it is still not working. I have tested in in three major browsers:

 

Opera v29.0

Firefox v29.0.1

Chrome v42

 

Perhaps I have firewalls blocking it or something as this site is in sandpit and not avail to public. I will have to go back to using the default asset builder uploader. Your plugin would be awesome if I was able to get it to work.


(Nic Hubbard) #15

and you just lost me...  :blink:

I just looked in firebug and can see that the ID is page_asset_builder_287482

 

I have changed the code but it is still not working. I have tested in in three major browsers:

 

Opera v29.0

Firefox v29.0.1

Chrome v42

 

Perhaps I have firewalls blocking it or something as this site is in sandpit and not avail to public. I will have to go back to using the default asset builder uploader. Your plugin would be awesome if I was able to get it to work.

 

It does work, just something coming into play here. I have extensively tested it on all browsers, and also built the implementation that you are trying to do...

 

Firewalls shouldn't be blocking anything.

 

Are you seeing js errors?

 

Hire me as a contractor. Don't pay me. And then I can login and take a look. Would be MUCH quicker.