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
There is a tag named 'smart_embed' that I coded way back into Couch v1.1. However, I decided not to document it as, I thought, it appeared to solve a problem that probably did not matter much.

A couple of sites I recently built made me rethink my decision. The smart_embed tag proved to be an absolute life-saver for me.

The concept behind the tag is a well known one amongst coders - Convention over Configuration (AKA also known as Coding by convention) where we rely on naming (file-names in our case) in-lieu of coding complex decisions.

I have made on-line a detailed explanation here
http://couchcms.com/docs/miscellaneous/smart_embed.html.

Would love to get your thoughts on it.
Neat addition, I definitely see how it can simplify embedding for complex sites.
Hey KK,

I decided to learn to use this feature, but it is not working as advertised.

At first I thought maybe I need to elide the extension on the templates
altogether. However, I found that even with versions of the filenames to
be embeded that have no extenstion, such that the smart_embed debug
output name and the name of the file are an exact match, the embed files
are still not being found. They do exist with the same name, in the different
chunk directories, so I am at a loss here.

I have also made sure they have the proper owner and file permissions.
They are the same ownership and permissions that are working fine for
the templates themselves.

Here's an ls -R of my 'snippets' directory renamed to 'embeds':
Code: Select all
ls -R embeds
embeds:
base  content  footer  header  menu

embeds/base:
donate-modal.inc  footer-end.inc    header-end.inc
footer-begin.inc  header-begin.inc

embeds/content:
about-default.inc              about-vendors-default.inc  events-list.inc
about-restaurants-default.inc  contact-default.inc        gallery-default.inc

embeds/footer:
default.inc         gallery-default.inc  news-default.inc
events-default.inc  index-default.inc    proprietors-default.inc

embeds/header:
default         events-default.inc   index-default      news-default.inc
default.inc     gallery-default      index-default.inc
events-default  gallery-default.inc  news-default

embeds/menu:
default.inc


And here's the output from my running template. I am simply told that
appropriate embed files can not be found. You can see in the headers
directory above that files with the exact same names exist, and yet
they are still not found.
Looking for files in folder embeds/header:

    about-default
    default

No suitable file found

Looking for files in folder embeds/menu:

    about-default
    default

No suitable file found

Looking for files in folder embeds/content:

    about-default
    default

No suitable file found

Looking for files in folder embeds/footer:

    about-default
    default

No suitable file found



Suggestions?!?

TIA!
@atenhotep

Hi, to me the folders look okay, so I agree with you it looks like it should work. However, just to be sure - because you've renamed the snippets folder can you please confirm where the "embeds" directory resides, is it within the couch folder or the base directory for the site?
Image
Yes, I have confirmed that 'embeds' is within the 'couch' folder. However, I have already
renamed the 'couch' folder. I like to take advantage of the security options. So, now
I am wondering if maybe the smart_embed code is assuming the 'couch' directory is
necessarily named 'couch'. In my case, it is not.

I guess, I could also try moving the 'embeds' direcotory to the root of the site, instead
of keeping it in the renamed 'couch' directory. The templates work in reference to the
changed name 'couch' directory no problem, but they are hard coded with change.
Can you please paste the line in your config file that defines the couch snippet directory name. It is relative to the site meaning it won't look for the snippets inside of the couch directory unless it is specified in the config file.

The reason I noticed this is that it is looked for embed/ instead of couch/embed for the snippets. Please paste the line and/or try adding the admin directory to the snippet definition in the config file :)
Image
Doh! My bad! Image

Once I moved 'embeds' to the root of the site, it was found.

I moved the original 'couch/snippets' to 'couch/embed', and missed
the comment in the config directly reminding you that the path is
from the root of your site, not the 'couch' directory.

I apologize for not going back and RTFM!
7 posts Page 1 of 1
cron