Closed (fixed)
Project:
Patterns
Version:
7.x-1.x-dev
Component:
Documentation
Priority:
Normal
Category:
Support request
Assigned:
Unassigned
Reporter:
Created:
9 Feb 2012 at 07:08 UTC
Updated:
20 Feb 2012 at 08:58 UTC
By chance, I found what appears to be the XML syntax for sub-patterns here. Something like:
<!-- execute pattern "news" -->
<pattern>news</pattern>I'm trying to write my patterns in YAML however, and am having trouble figuring out what the proper syntax should be.
Looking in the documentation, I don't see any info on how to implement sub-patterns.
I've referenced the module packaged documentation, and these online pages:
http://drupal.org/node/346509
http://drupal.org/node/408940
Comments
Comment #1
shakty commentedHi,
unfortunately, in the 7.x branch sub-patterns are disabled for now.
The documentation you are referring to, is for Patterns 6.x, and there are a few changes introduced with the 7.x version. Please refer to the doc folder inside the patterns module directory. That should be enough, but if that is not clear you can just ask here.
Here is an example for a YAML pattern.
Comment #2
davidcsonka commentedThanks! I'm learning the YAML syntax pretty well, was just wondering specifically about the sub-patterns. I see that you say it is disabled in the current version of Patterns 7.x
Could you provide an example of how it would look though? Thanks
Comment #3
davidcsonka commentedAre relation and parent attributes for taxonomy terms allowed in the current 7.x branch of Patterns?
I can't get those to work either, nor can I find examples of the proper syntax for utilizing the parent or relations attributes in a Pattern YAML file.
The Taxonomy Syntax documentation here (http://drupal.org/node/408954) doesn't provide any examples. There are no examples provided in the packaged module documentation either.
So, I guess that begs a more important questions. Is there a need for help to expand/update the documentation for Patterns?
As somebody who is new to the module, but desperately wants to make use of it - I can see a need.
Comment #4
shakty commentedHi davidcsonka,
many questions, here are some answers:
- we haven't fixed the syntax for sub-patterns yet. We were concentrating on other issues first. You could propose a syntax which looks intuitive for the users, we would be happy to discuss it.
- as for parent attributes for taxonomy terms, they should work, I am going to double check them and let you know.
- and I think yes, definitely we need better documentation! Again any help, suggestion, critique is very welcome.
Cheers.
Comment #5
shakty commentedAll right, I just pushed a fix for the using parent relationships in taxonomy terms. That should work.
Just get the latest code from git with this command:
git clone --branch 7.x-1.x http://git.drupal.org/project/patterns.git
Here an example how to use it:
Comment #6
shakty commentedComment #7
davidcsonka commentedThank you for the info. In regard to documentation, I will see if I can help out by updating those older documentation pages on drupal.org with syntax examples, as I learn them.
Regarding parent terms, and your fix. I pulled down the new version and installed it. However, it doesn't seem to work, and I get an error.
I used this pattern:
It produced the two terms when run, but the child term does not get the "Parent" term set as it's parent. No relation is created.
Also, I get this error when going back and forth from the Pattern edit screen, when verifying that the pattern is valid.
TYPE php
DATE Friday, February 10, 2012 - 10:24
USER admin
LOCATION http://localhost/admin/patterns
REFERRER http://localhost/batch?op=start&id=7
MESSAGE Warning: Invalid argument supplied for foreach() in _patterns_scan_pattern() (line 338 of C:\xampp\htdocs\sites\all\modules\patterns\includes\patterns.parser.inc).
SEVERITY warning
HOSTNAME 127.0.0.1
Comment #8
davidcsonka commentedAlso, does this new dev version require the module: Macro?
7.x-1.x-dev Enables extremely simple adding/removing features to your site with minimal to no configuration.
Requires: Token (enabled), Libraries (enabled), Macro (missing)
This seems changed from the previous version, and Macro isn't even developed for Drupal 7.
Comment #9
shakty commentedHi,
actually, there is a version of Macro for Drupal 7...I know because I pushed it there. It does not show up on the main page, because it is still experimental, but you can download it with git or from here:
http://drupal.org/node/430278/release
or with drush.
Please tell me if after installing macro you still get the error, and I will look into that.
Thanks for the precious help!
Comment #10
davidcsonka commentedOk, I installed that version of Macro and the modules interface didn't indicate there were any problems. However, when I have that test YAML pattern in the patterns dir, I still get that ForEach error. Slightly different though, because the referrer mentions modules, rather than batch.
TYPE php
DATE Friday, February 10, 2012 - 15:17
USER admin
LOCATION http://localhost/admin/patterns
REFERRER http://localhost/admin/modules
MESSAGE Warning: Invalid argument supplied for foreach() in _patterns_scan_pattern() (line 338 of C:\xampp\htdocs\sites\all\modules\patterns\includes\patterns.parser.inc).
SEVERITY warning
HOSTNAME 127.0.0.1
If I remove all the other patterns from the dir and just put this one instead:
It doesn't throw any errors.
Comment #11
shakty commentedHi,
sorry for coming back to you so late. I actually can't reproduce your warning.
Do you get it with the standard files which are included in the pattern module, or did u already write some custom ones? If so, it would be very interesting to know which files is creating the error.
Besides this warning, are parent relantionships working for you now ? They are, on my environment.
Let me know!
Comment #12
davidcsonka commentedThe standard sample files which come with the Pattern Module do not provide examples of adding parent terms, or sub-patterns. Otherwise, I probably wouldn't have needed to post my questions here. :D It would be nice if the module shipped with example encoded files for these types. I can find no documentation *anywhere* explaining how to do those things.
Anyway,
I don't get the "forEach" error when running most of my pattern files, that validate fine.
I mainly get the error when trying to run this custom pattern:
It' just a small sample encoding to try and test the syntax which you explained to me for adding parent terms. It validates, but when I run it - it does *not* set the parent relation.
Comment #13
shakty commentedHi,
I just pushed a fix which should finally make your pattern work.
Regarding the foreach issue, the problem is that the yaml file you pasted here is malformed. In fact the separator in the last line is a big tab instead of spaces, as it is before. It is actually strange that you could save / import that file. I will investigate this issue later on.
Please tell me if the parent relantionships are now correctly set.
Cheers.
Comment #14
davidcsonka commentedThat's pretty obnoxious that YAML is such a stickler for that kind of syntax! It seems to me that XML would be easier to use, but there were less examples provided in the XML format, so I didn't have much choice.
Thanks for working on this and teasing out the problem with me. I plan to utilize Patterns a great deal for my site migration/staging efforts, it's a such a great concept.
I will need to wait for the patch to be merged before I can download the new deb branch?
Comment #15
shakty commentedYou can download it from git. If that works, I close this issue.
Comment #16
csko commentedI've added the dev branch to the releases as well as created a tag for the latest version. Both contain these changes mentioned here.
Comment #17
davidcsonka commentedThis worked, thanks! Also, thank you for the insight into the error cause, being the issue with tabs vs. spaces. I didn't realize YAML was so specific.
Comment #18
shakty commented