Coded something up in Couch in an interesting way? Have a snippet or shortcode to share? Post it here for the community to benefit.
7 posts Page 1 of 1
My user wanted the ability to upload a variety of pdf's and other non-image files and then provide links to them from richtext or nicedit entries anywhere in the site. Neither of these types seem to have a file upload option so I did the following.

1. Created a hidden page called files.php

2. Created a repeating file upload template:
Code: Select all
        <cms:template>
            <cms:repeatable desc='Upload the files here' label='Files' name='files'>
                <cms:editable
                    name='uploadedFile'
                    label='Uploaded File'
                    type='file'/>
            </cms:repeatable>
        </cms:template>


3. Output the file list as links with the name of the file:
Code: Select all
    <cms:show_repeatable 'files'>
                 <p>
                 <a href="<cms:show uploadedFile/>" class="_contentlinks"><cms:show uploadedFile/></a>
                  </p>
    </cms:show_repeatable>

4. Gave the user the following procedure:
    a. Upload the file(s) in the files page in the admin panel and save.
    b. Open or refresh the 'files.php' page.
    c. Right click on the required file link and select 'copy link address'.
    d. Paste this into the desired link field in the text editor and select the required 'Open in' option.

Seems to work fine if a bit of a cludge. There is probably a much easier way to do this - happy to learn....
Graham
Hi Graham. At least when it comes to the richtext editor, I think I can help you reduce the cludge. I don't use nicedit.

The KCFinder file manager is aware of the appropriate file type for a given input. So when you're uploading images, it shows your image folders. When you are adding a link, it shows your file folders. Allow me to demonstrate.

In the richtext editor, select the link text then hit the "link" button. Bang on the "Browse Server" button.
link.png
link.png (20.44 KiB) Viewed 4866 times

You can now select one of your previously uploaded files or upload a file directly from the finder.
upload.png
upload.png (49.77 KiB) Viewed 4866 times

So at least when it comes to the richtext editor you can avoid all of the copy and paste rigamarole, and possibly get rid of the separate template all together.
Thanks Tim,
I had actually missed that because pretty most of the text fields where I want to place asset links are in repeating regions so I cannot use the richtext tag.

The nicedit link (and image) dialogs are just a basic link.

I will be able to reduce the use of the files template but not eliminate it.... :(
Graham
@GrahamO, the v2.0 available from GitHub (https://github.com/CouchCMS/CouchCMS) now supports the use of 'richtext' (i.e. CKeditor) as a repeatable region.

If you are using v2.0 (or can migrate to it), I suggest you download it from the link above and use it.
Thanks KK,
Its good to know but I'm a week away from my first CouchCMS site going live and feeling a tad cautious. I think I might wait until I have read the formal documentation....

I did read some of the V2 thread and I was a bit concerned about the "when is Redactor coming?" comments. I am having to do some work on a CraftCMS site at the moment (another story but I'm sticking with Couch) and I am finding Redactor II particularly irritating. The main issue for me is lack of user control over the layout of embedded images. you cannot (as far as I have been able to tell) have images anything but native size and inline. There are no sizing or wrapping options at all.

The "don't let the user do anything with styling" approach smacks of techno-elitism to me. I have technically sophisticated users who want to be able to layout their content flexibly. Hopefully you will be able to give us Couch users a choice of text editor for richtext fields or build a decent Redactor image styling plugin if you decide to go that way?.....

KK wrote: @GrahamO, the v2.0 available from GitHub (https://github.com/CouchCMS/CouchCMS) now supports the use of 'richtext' (i.e. CKeditor) as a repeatable region.

If you are using v2.0 (or can migrate to it), I suggest you download it from the link above and use it.
Graham
You can relax if Redactor is not for you, Graham. It's not meant to replace CKEditor, but will be made available as an alternative.
Excellent! It is a bit too skinny for my tastes but I guess that will depend on the project.

tim wrote: You can relax if Redactor is not for you, Graham. It's not meant to replace CKEditor, but will be made available as an alternative.
Graham
7 posts Page 1 of 1