Forum for discussing general topics related to Couch.
9 posts Page 1 of 1
I'm still feeling I'm rather swimming against the current with CouchCMS, as there are some pretty simple things I'm finding difficult to do. I'm sure I'm just going about them the wrong way. One such is to do with the mix of native PHP code with Couch template use. I want to display one bit of HTML if today's date is within a certain date range, another if it's in a different date range, and so on.

With native PHP I'd probably simply compare DateTime objects and use different heredoc contents. But I'd like to use the clean tags of CouchCMS instead if I could. Can I concoct some kind of suitable test for the cms:if tag using native PHP? Or is there some other way I should be doing this instead?
Comparing dates can be done with Couch tags, but it would require unnecessary hassle (converting to Unix seconds to make basic calculations).
Code: Select all
<cms:if "<cms:php> ...your code here..; echo $in_range; </cms:php>" >
...
<cms:else_if "..." />
..
<cms:else />
..
</cms:if>

Above is an example how to use php stuff with conditionals. To make things easier to review,
place your code to a Couch variable and use that variable in conditional. Let me know if you need help with that.
Thanks for that. Could you please give me an example of assigning a value to a Couch variable via native PHP? I think that's the part of the jigsaw I'm missing.
Code: Select all
  global $CTX;
  $CTX->set( 'my_couch_variable', $name );

Sample above creates a a couch variable from withing a large block of php code.
There are lots of samples on this forum. Keep searching :)

Edit: another way is with 'echo' for smaller pieces:
Code: Select all
<cms:set variable="<cms:php> echo $var; </cms:php>" /> or
<cms:set variable="<?php echo $var; ?>" />
Thanks, that's very helpful!
Johnny2R wrote: Thanks, that's very helpful!

Welcome! Share with us what you designed here. :)
I'm with Johnny on this one. I've spend 15 minutes getting a login for this forum which I'm only ever using to post this comment, after that I'm history.

Couch looks really good, so good in fact that it's half way to becoming the best CMS I've seen so far. What really needs to be done is stop wasting time implementing these "Couch" specific keywords, because they will never reach a point where a serious content programmer is satisfied with them, there is always something small that can't be done with built-in couch functions that will stop you dead in your tracks. Just like the original poster above, the only solution is to hack the underlying PHP files, which is no good at all! Looks like you only have a few hundred users, when you could have hundreds of thousands if implemented properly.

You need to put a hook in there for php calls and have a basic minimum of Couch functions just to get things going. You need better templating and component declarations too. If you stop trying to cater for users who have NO PHP knowledge and instead harness the fact that you are actually using a PHP backend, then you will have a winning system, until then it's just another wannabe CMS which is stuck between two worlds, designer and programmer. You need to work out which you cater for. What you provide now is not much more than most of the static CMS's provide, but yours need a slow PHP backend to get it running on a client site. Such a waste.

I'd suggest you keep your petty Couch functions but also provide a PHP hook to allow users to call php within a particular component/template. Use Metal: frameworks and trying to imitate the exact functionality of PHPTAL, which was dropped years ago and replaced with other templating systems, none of which have the simplicity, power and cleanness of PHPTAL. Even the original Wordpress creator mentioned PHPTAL was the only serious templating system at the time. Things haven't gotten any better in the templating world, in fact they're more cumbersome.

Couch has the clear advantage that it requires HTML formatting for it's tags and they even look like XHTML, which is even better for you.

If you mod couch to replace PHPTAL templating and keep your existing CMS engine, then you'l have a real winner of a product!

I hope you do well.
Thanks, @DannyBoy

Your comment is clearly adressed to @KK, but I thank you personally for the effort and a great post!

I am taking this amazing thread opportunity to invite anyone *with* knowledge of PHP to commit anything to it. As a light example (link), devs can create their own versions of couch tags.
while executing any tag Couch first fires an event (alter_tag_<tag_name>_execute) to allow any custom code to override the behavior of that tag

Another available opportunity is to create their own tags and share them with others. Raw php also can be used without any restrictions, because it has a priority over anything, couch-based.

Personally & so far, I am not happy that there is a certain ceiling of Couch learning curve and probably you, @DannyBoy, as a phpdev see it more clear than any front-end guy.
But, I pay my tribute to
Custom routes,
Extended entities and composite queries,
Applications,
etc.
Those made me up to the work of creating such powerful websites, that I never dreamed of ever coming close.

I respect that you are history and probably never come to this thread again.

I want to remind everybody that there is a bunch of tools to use, when it comes to feature requests or highly specialized feedback, which a majority of forumites probably won't understand, unless @KK creates a nice tutorial to explain high-end stuff to people like me, *without* extensive experience with PHP.

So, direct PM to @KK, email, or Feature Requests subforum are better places for the purge. I appreciate your comment, but probably in several days would move it to Feature Requests, as I'm sure this can do some good to make things a bit ordered for search.
@DannyBoy

I have a feeling you misunderstand the point of couchcms. If you're a full fledged PHP developer you probably don't need couch and move to Lavarel or something like that, or you decide to contribute and help out KK with his work.

I totally agree with @trendoman. If someone like me need a cms or some basic stable php code to start building on, and lacking PHP experience/knowledge couchcms becomes suddenly a powerful tool to work with and makes it ,for me, possible to create stuff what is otherwise completely out of my reach.

So for everyone who is going to propose ...
stop trying to cater for users who have NO PHP knowledge

Please don't !

For sure there is a way to support also real PHP developers.
I load frameworks and write bugs on top of them, after that I rearrange the code so that it looks like a cool product.
9 posts Page 1 of 1