Coder Social home page Coder Social logo

spicywebau / craft-neo Goto Github PK

View Code? Open in Web Editor NEW
403.0 15.0 63.0 10.73 MB

A Matrix-like field type for Craft CMS that uses existing fields

License: Other

PHP 64.65% JavaScript 24.88% SCSS 3.75% Twig 6.73%
craftcms craft-plugin craft-field craft3 craft4 craft2

craft-neo's People

Contributors

alumpe avatar andris-sevcenko avatar benjamminf avatar boboldehampsink avatar brandonkelly avatar davidhellmann avatar dependabot[bot] avatar dwhoban avatar engram-design avatar gglnx avatar lavandongen avatar leevigraham avatar mattwilcox avatar myleshyson avatar nickdunn avatar nstcactus avatar oliver-amann avatar pvldigital avatar rexterkate-adwise avatar scandella avatar smcyr avatar ttempleton avatar verbeeksteven avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

craft-neo's Issues

Duplicate Block

It would be a great piece of functionality if it was possible to duplicate an existing and already built block when adding content... with all of the sub fields in tact (although they don't necessarily have to be filled out, for my use case at least)

Move block up/down options

Sometimes blocks can get pretty long, if they have a lot of content or children in them. Dragging them to change their position can get a little clunky in these cases. Would be good to have an option on the dropdown menu for each block to move their positions up and down as an alternative to dragging.

Limit child blocks applies to all parent blocks

I have a columns block which has column child blocks that are limited to a maximum of 4.

In the scenario I currently face, I have added 1 columns block with 4 (the maximum) child column blocks.
If I add another top-level columns block, it already imposes the limit on adding more children (by graying out the button to add a column).

Bug: Using asset field with {slug} as upload location

Hi Benjamin.

First of all, LOVE the plugin. It's how the Matrix should work by default.
But I'm having a error when uploading an asset file (S3) with a preset upload location with {slug} as variable. The error is only showing when using the field inside Neo. As standalone field it's uploading fine.

This is the error: Could not resolve the subpath “{slug}”.

screencapture-portfolio-craft-dev-admin-entries-case-4-925-1464182877977

Documentation With Templating Examples

Thanks for a brilliant plugin!

Would love to eventually see some documentation with examples of templating and so forth. Various basic use cases perhaps.

Max Child Blocks

We can limit blocks by type but it would be nice to limit child blocks to a set number to allow a choice of which blocks they want to use.

Currently if I have 3 child blocks I can set a max of 3 to each meaning they can get up to 9 child blocks. If I set 1 max to each type they can only use 3 but have to use one of each.

Drafts not saving any fields

When I'm creating/updating/editing entries in Draft mode, none of the fields in my Neo field are updating, including Rich Text, Plain Text, Assets, Dropdowns, etc. This only happens on Draft mode though, and only when I save a Draft. Live Preview is working fine on Draft mode (all my additions/edits are showing up as expected), however when I save the Draft and the entry edit page refreshes, all of the changes I made on my fields are wiped away.

This issue doesn't happen (my changes do save and carry over when the entry edit page is refreshed) if I'm in Draft mode, enter in my changes/additions in the fields, and then Publish my draft. The new live published version of the entry has the changes I made to it when I was editing the Draft. It also doesn't happen on edits to published entries or even disabled published entries - every time I save those, the changes I make in the fields don't get wiped away. It seems to only happen on Draft saves.

I'm seeing the issue on dev, staging, and production environments, so I don't suspect it's a server issue.

Override field instructions

Because Neo is re-using fields, writing instructions for clients need to be generic so that one field can be used in different situations. Sometimes generic is okay, but sometimes its not clear enough and that would warrant creating a separate field just to accommodate the different instructions. It would be great if we have the ability to override a field's instructions so we can give clearer direction to clients on a per-field basis.

It could be something to replace the instructions on the field, or maybe additional text that can appear below the field.

Revert to version

Hey benjammin,

I just noticed that you can't revert an entry to a previous version, the Neo field is just empty. Is this a known bug? Do you think this feature will be available in the near future?

Cheerio
Sidney

Add block type/group after selected one

Would be handy to have block types and groups added after the currently selected one in the configurator. Saves having to reorder every time you add a new one.

Check if field exists

Hi, I'm trying to check if a field exists in a neo block. I'm following this suggestion (but for a matrix field) and I can't get it to work:

{% for block in blocks.level(1) %}
  {% if block['foo'] is defined %}
    yep
  {% else %}
    nope
  {% endif %}
{% endfor %}

It will output 'true' if the field exists anywhere in Craft, even if its not present in the block. Am I missing something?

Thanks in advance.

Blank Tabs

In some cases, I would like the first tab in a block to be blank. For example I have a block called "row". It has options, but this block is just a simple container for child blocks and the options are rarely used. I don't want to see them all while adding new rows. In the field layout I create a tab with no fields in it and then another tab with all the optional fields.

When I go back to an entry, this is not respected. Then when I go back to the NEO field settings, the first blank tab I created is gone.

Duplicate a whole Neo field? Possible "Field Manager" support?

A field has to be unique within a section in Craft right? So it's not possible to have a Neo field in a "main content" tab, and then another instance of the same field in a "sidebar" or "footer" tab on the same section.

I tried cloning a Neo field with Field Manager. While the clone was successfully created, all the fields were removed from the original Neo field (silly me should have done a DB backup right before trying this, but I'm sure I can work out how to reassign them back to the original in the DB).

So my question is - how might I go about reusing a Neo field on the same section?

  • Is there an easy way I'm unaware of perhaps? Is duplication the only way?
  • Could Neo work with Field Manager? Would that be handled on your end, or Josh Crawford's?
  • Or could a duplicate/clone option be added to the Neo field settings page? Probably a pretty extreme option?

Thanks

Multi locale Matrix Blocks - Blocks and content deleted on save

Hi,

I have an issue with a Neo Field that consists of 3 block types.
And each block type has a matrix field in it.
The Neo Field and the matrix fields are all set on translatable.

screen1

The two locales are NL (Dutch) and EN (English), with dutch as the primary.

If I add a block for the first time in the Neo field on the English locale, then the matrix field in it has the Dutch locale enabled. See the screenshot, the locale EN for the field is displayed and the matrix block is set to NL instead of EN.

screen2

If I add in some matrix blocks with content, all blocks and the content inside are deleted on save. The next screen shows the result after saving:

screen3

So the locales of the matrix blocks are now set to the right one: EN. And if I add in matrix blocks, now it gets saved.

Have an Idea to fix this?

With kind regards,
Ruben

Fail after save field

I wanted to test. Build a Simple Neo Field with two Blocks not more. Click on Save than a CException

/craft/app/framework/db/ar/CActiveRecord.php(146)

 */
public function __get($name)
{
    if(isset($this->_attributes[$name]))
        return $this->_attributes[$name];
    elseif(isset($this->getMetaData()->columns[$name]))
        return null;
    elseif(isset($this->_related[$name]))
        return $this->_related[$name];
    elseif(isset($this->getMetaData()->relations[$name]))
        return $this->getRelated($name);
    else
        return parent::__get($name); => Error
}
/**
 * PHP setter magic method.
 * This method is overridden so that AR attributes can be accessed like properties.
 * @param string $name property name
 * @param mixed $value property value
 */
public function __set($name,$value)
{
    if($this->setAttribute($name,$value)===false)
    {

Tested with Craft 2.6.2781

Live Preview not updating with Neo field

First. This plugin changes everything. So well done. Thank you!

I've just built a pretty robust Neo-based install using our internal Live Wires prototyping library. It works amazingly well, there' just one small hitch we're running into… Live Preview doesn't refresh when editing the Neo field.

Possibly related: I had the same issue with another Craft install with the Matrix field when Eager-loading was implemented. Removing eager-loading helped. Same issue as this: http://craftcms.stackexchange.com/questions/8879/issue-with-matrix-type-property-and-live-preview

Not sure if it's just the sheer size of this field, or something else.

Feel free to try out the install for yourself (auto resets every night): http://demo.livewires.io/admin u:admin p:password)

Also here's the repo if you want to see the code used: https://github.com/louderthanten/craft-editorial-system (this field uses the _content.html file and _content folder to render the field).

Templating Question

Any chance you could share an example of how one would go about templating the setup shown in the wiki under "2. Creating Neo fields"?

I'm also wondering if there's a way to use the switch for the various types, or just do if/elseif/endif.

I'm referring to this;
creating-field

Automatically convert Neo fields to Matrix fields when uninstalling the plugin

In response to the concern about using Neo given it's a third-party plugin, I figured adding graceful degradation would help people feel more confident using it.

Neo fields and Matrix fields obviously aren't 1:1, so there will be a minor loss of information — specifically, block hierarchy information will be lost — but it's better than losing everything.

Can't save field if new block previously had errors

  1. Add a new block, but make sure it has an error (like a required field missing a value)
  2. Attempt to save the element - an error will throw
  3. Fix the error shown in the new block
  4. Attempt to save the element again - the same error will throw again

Matrix Block Dropdown Groups

First of all, thanks for this great plugin. I was using PMM, but ultimately Neo suited my specific needs. One thing I miss that I'd like to request is dropdown groups:

dropdown groups

I was thinking this could be a managed somewhat like so:
concept_ui

Thanks again for all your hard work on this!

Question: Craft 3 plans

Hey Ben, do you currently plan to port Neo to Craft 3 (in due course)?

I understand that Neo is a hobby project and that you can't commit to anything definitively, but Craft 3 is getting close enough that we need to make sure there's an upgrade path for our client sites, and that means thinking carefully about potentially plugin use, especially those that are both fairly substantial and OS, so I wondered if can give any guide at the moment?

Thanks for your time!

Multi level reorder

It would be super helpful if blocks could be dragged in and out of different levels.
At the moment, if you have a block as a child of say a column block, then you have to recreate it if you now need it to be in another column.

Invisible fields

I've used Neo to add content to my homepage.
Everything worked fine and my homepage does display the content.
But after a while I wanted to change some content and all I saw was one field. The content is still there on the homepage, but I can't see the fields.
When I try to add another field it won't show either (because of the max fields, I do know that a field is added but no is shown). When I add a field above the one field that is displayed, It does shows up.

Edit: same bug #25

DB issues on installation

Not sure if anyone has seen this before:

CDbCommand failed to execute the SQL statement: SQLSTATE[HY000]: General error: 1215 Cannot add foreign key constraint. The SQL statement executed was: ALTER TABLE `craft_neoblocks` ADD CONSTRAINT `craft_neoblocks_ownerLocale_fk` FOREIGN KEY (`ownerLocale`) REFERENCES `craft_locales` (`locale`) ON DELETE CASCADE ON UPDATE CASCADE

Not sure what to do here.

can't save can't update

  • sometimes an entry with a neo field will not save. unless I add a new block, then it will save. BUT if I delete that newly added block, the entry again will not save. no warnings. nothing. (v 1.0.2 )
  • upgrading from 1.0.2 to 1.1.0 screws up the database, specifically... can't find (unknown) neoblocks.sortOrder column

Search keywords aren't getting generated

Searching Neo fields on elements is broken. Problem being that the search keywords method incorrectly starts a task to generate the keywords, where it should be returning the keywords only. Need to move the task to the onAfterSave() hook method and have the getSearchKeywords() just return the currently saved keywords.

Server-side validation to max blocks by type and valid child blocks

Currently the restrictions for limiting blocks by their type, and blocks owning child blocks, are entirely cosmetic (in other words, it's only enforced with client-side Javascript). This is fine for the most part, but if someone were to change the rules for a Neo block type, some current values of that field may then violate these rules. At the moment, you're able to continue saving these field values as if nothing has happened. Adding server-side validation will report these conflicts after a save.

Child block gets added to wrong parent

  1. Add two root level blocks
  2. In the first root level block, add a new child block
  3. In that new child block, try adding a child block. It will add it to the last block instead.

Translations needed

Seeing as I'm an uncultured bogan who can't speak anything other than aussie, additional phrases that need translations are

Configurator

  • Block type
  • The maximum number of blocks of this type the field is allowed to have.
  • Child Blocks
  • Which block types do you want to allow as children?
  • Max Child Blocks
  • The maximum number of child blocks this block type is allowed to have.
  • Top Level
  • Will this block type be allowed at the top level?
  • Define the types of blocks that can be created within this Neo field, as well as the fields each block type is made up of.
  • Delete block type
  • Delete group
  • Unable to nest Neo fields.
  • Are you sure you want to delete this block type?
  • Are you sure you want to delete this group?

Input

  • Add block above
  • Duplicate block

Converting Neo to Matrix

  • This field is currently of the Neo type. You may automatically convert it to Matrix along with all of it's content.
  • Convert
  • By converting to Matrix, structural information will be lost.
  • Are you sure? This is a one way operation. You cannot undo conversion from Neo to Matrix.
  • Could not convert Neo field to Matrix

Obviously not very important, but if anyone has some spare time to translate these phrases into a language they're fluent with, I'll write nice things about you in the README and maybe order you a pizza.

(If you are actually going to do this, I'm happy for you to either open a pull request with the translations implemented or just post them here)

How to Output the Children on a Block

Hi

I'm new in Craft. How can i output the children of a block?

With this code a don't get a output for the children. Sorry if my code looks nooby, i'm a craft beginner.

{% for block in entry.body.level(1) %}
    {% switch block.type.handle %}

        {% case 'boxContentImage' %}
            {{ block.richText }}

            {% for item in block.children %}
                {{ block.something }}
            {% endfor %}

        {% case .. %}

    {% endswitch %}
{% endfor %}

Plugin causing JS alerts from garnish.js (Version 1.3.5 )

I've just upgraded to version 1.3.5, and now, when I open an entry that uses Neo, I see this alert in the Chrome JS console: "Double-instantiating a transparent text input on an element" - garnish.js:6535

I'm not sure this is actually causing a problem with the plugin's functionality, but the notice was not there before.

Duplicate all selected blocks

The duplicate block feature currently only duplicates the block you select the "duplicate" menu item on. Would be handy to be able to duplicate all the currently selected blocks.

Always prompted to leave/stay

Having a super minor issue with the javascript prompt for Staying/Leaving showing up without any changes actually made.

Rich Text fields not initialising

I've noticed that Rich Text fields are not initialising within Neo. When a block is added with a Rich Text field inside, a JS error is thrown and the Redactor field is not loaded.

Uncaught TypeError: Cannot read property 'opts' of undefined

Rich Text field failing to load

I believe this is related to the following:

/*<![CDATA[*/
$.extend($.Redactor.opts.langs["en"], {
    "fullscreen": "Fullscreen",
    "insert-page-break": "Insert Page Break",
    "table": "Table",
    "insert-table": "Insert table",
    "insert-row-above": "Insert row above",
    "insert-row-below": "Insert row below",
    "insert-column-left": "Insert column left",
    "insert-column-right": "Insert column right",
    "add-head": "Add head",
    "delete-head": "Delete head",
    "delete-column": "Delete column",
    "delete-row": "Delete row",
    "delete-table": "Delete table",
    "video": "Video",
    "video-html-code": "Video Embed Code or Youtube\/Vimeo Link"
});
new Craft.RichTextInput({
    "id": "fields-blogBody-new0-fields-text",
    "linkOptions": [{
        "optionTitle": "Link to an entry",
        "elementType": "Entry",
        "sources": ["singles", "section:3", "section:2"]
    }],
    "assetSources": [],
    "transforms": [],
    "elementLocale": "en_gb",
    "redactorConfig": {
        "buttons": ["format", "bold", "italic", "lists", "link", "file", "horizontalrule"],
        "plugins": ["source", "fullscreen"]
    },
    "redactorLang": "en"
});
/*]]>*/

It's possible to trick the fields into working, if a Rich Text field is added to the section outside of Neo, for example:

Tricking the Rich Text field into loading

I'm currently using Neo 1.3.3 in a fresh install of Craft 2.6.2903. I've not installed any other plugins and created all the fields from scratch.

If there's anything else I can give you to help, please let me know.

Thanks in advance,

Tom.

Block Tabs

First thanks again for your work and an awesome plugin. While playing around with it I noticed two small points:

  • The block tab titles (when you create multiple tabs for a block) don't get translated
  • The block tabs trigger also the checkbox to select the block

Performance

Hi Benjamin.

I'm just wondering if you've hit many performance issues with Neo yet? I have a pretty large Neo field that includes an awful lot of fields including quite a few Matrix fields. I find saving a page with the Neo field is quite slow. I've had a couple of errors when my php memory was set low at 8M, but it's been upped now and although slow, I've not had any errors. I haven't tested properly yet and I'm sure there's some optimisations I can make, just wondering if you've hit anything yet?

1.1.1 Install Triggers Manual Update and Database Error

Craft 2.6.2789

  • Dropped a brand new Neo folder into Plugins on an existing install.
  • Got the message: "To complete the Neo update, some changes must be made to your database."
  • Clicked "Finish Up"
  • Works for a little while, backs up database, then "Rolling back.."
  • ERROR: "Craft was unable to install this update :( The site has been restored to the state it was in before the attempted update. There was a problem updating your database."

What do you think this could be all about?

This is in the URL. Why?
../admin/manualupdate/neo

Draft preview links don't work

With the latest release, Draft tokenized links don't display correctly (or maybe this has always been the case?). If I save an existing entry as a draft and make edits to the draft, when I click the arrow to take me to the tokenized draft link, the changes that we make aren't displayed there and instead displays the current live version. Live Preview works just fine on the Drafts though and when I publish the Draft, the changes that I made in it do overwrite the existing version so that is working as well.

Unfortunately our clients do use the Draft mode quite frequently to get feedback and approval for changes and new layouts for their pages, so we've had to hack up a couple workarounds to that that aren't ideal (duplicate entry, disable the duplicated entry, make edits, and use that link to share out -- disabled entries that have tokenized URLs work just fine with edits/changes).

I took a look at the closed issues and saw that there was another issue relating to Drafts but that seems to have been fixed? So I believe this one is different however I could be wrong.

Thanks so much, other than this small issue we are loving Neo and hope that the Craft team can make it part of the core build at some point!

1.1.1 broke all content on our site.

Since updating to 1.1.1, all Neo matrixes on our site are broken. The CMS has become obsolete and we have to revert to a previous backup. Here is a list of problem we encountered:

  • Only one NEO block remains on each field, not always the first one.
  • We can only add a block using the "add block above" option. (the block has a white handle). Another "fix" for this is disabling then enabling a block and then save the entry.
  • When we finish putting back the content that has been lost, we then visit the page with the neo feild it breaks the content in the same way again. Exept the content is still displayed in the front-end but not in the CMS (the order is also different then what we saved). The bug where we cannot add a block happens again.

What happened there?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.