Active
Project:
Entityreference prepopulate [D7]
Version:
7.x-1.x-dev
Component:
Miscellaneous
Priority:
Normal
Category:
Support request
Assigned:
Unassigned
Reporter:
Created:
6 Sep 2012 at 16:02 UTC
Updated:
11 Feb 2015 at 22:35 UTC
Jump to comment: Most recent
Comments
Comment #1
jonthomas83 commentedI've been trying to figure out how to use "Flag" for this, but no such luck just yet.
Thanks for the great module but a link to "Create new content" from referenced nodes is essential in my opinion. Any ideas how we can do this?
If you need help writing documentation for this awesome module, let me know, just need to know what you want me to write! :)
Comment #2
jmary commentedMy project is already using the module display suite (DS)(http://http://drupal.org/project/ds). As that stuff can do far much more that its name lets expect, I went to find a solution there. You don't need the Extra part of display suite, the basic one is enough.
In this example, I work with two node types : Contact and Note. I want to create notes which are referring to a contact. Also when a contact is displayed, I want to have a link "Create a note", sending me to node/add/note?field_refer_to=nid
It takes 2 minutes.
<a href="/node/add/note?field_refer_to=%node:nid">Create a Note</a>Comment #3
kaizerking commented@ jmary, I haven't tried this yet , can we limit the number of new nodes which can be created using this i.e limit the new nodes per reference per user?
Comment #4
jmary commentedI think it is possible at adding a code field in DS in place of a dynamic field.
But I think in this case, it becomes useless to use DS as the scope was to avoid to write any code.
Better to put the link directly in the nodetype template file at displaying it only when the test regarding "how many the user has created" is validating or not.
I won't cover that but the roadmap to do so is :
- write the code counting how many nodes of a given type the current user has created
- write a if block with your test
- display the link with the current node id
However this will only prevent the link to appear, it is still possible for the user to create some content at using the direct link /node/add/nodetype. You may try http://drupal.org/project/node_limit to avoid that.
Comment #5
kaizerking commentedin that case there is simpler solution reference dialog
it works conceptually very nice to create a node inline
The functional issue with any of this kind are:
1. it should have control on how many can be created
2. Node id should not be displayed along with the title, this gives a wrong idea to the creator issue here prevent display of node id after creation
3.Should not be extended to inline editing of newly created node
4. The link should disappear after create limit expires
5. I am aware of node limit, that cant be a solution but ideas can be picked up from there. because what we are talking is node limit per reference per user and not Node limit per user
May be you could pick some ideas from there instead of carry the weight of DS for this simple issue
EDIT: Safer approach, the newly created node only should be saved if the host node is saved. that would perfectly prevent spam but I doubt if that is possible some thing like create a node with a set default if like %%%%%=nid keep it till the save button of host node is clicked. save the new node before the host node is saved, then save the host node
Practically i don't know if this is possible, but I know there are applications other than drupal which use this kind
Comment #6
azuledu commentedLook at this project:
http://drupal.org/sandbox/hazah/1488826
Comment #7
rwilson0429 commentedI was able to add a link on the referenced node using Views and EVA modules.
The EVA module allows you to attach a view to any entity using an EVA Field Display in the View.
'/node/add/[YOUR-CONTENT_TYPE]?[YOUR-ENTITY-REF-FIELD-MACHINE-NAME]=[nid]'I wanted my user to be returned to the referenced entity after adding child content so, I used the following PHP snippet instead in my View Header:
Comment #8
sportel commentedHi rwilson0429,
Thanks for your suggestions. I'm sorry for my noob question, but can you tell me where to put the php-snippit?
Thanks,
Mike.
Comment #9
rwilson0429 commentedsportel, you can put the snippet in any Text Area in the View. I put the snippet in the View's global Footer section and added a Global:Text Area where I placed the code. Note, you must use the php code text format for the php code to be interpreted properly.
You don't need to include the php comments (lines starting with //) in the snippet, it's there for reference only.
There are so many ways to do things in Drupal. I'm certain there is a better way (don't like putting php in a View) but, this worked for me.
Hope that helps until a better solution is offered.
Comment #10
sportel commentedThanks, works, simple, my mistake. I didn't have the php filter module (core) installed. Good work. But, I'm also interested in a more out of the box solution, instead of using php-code. For now, it works. Thanks.
Mike.
Comment #11
kaizerking commentedUse rules link its working
Comment #12
guy_schneerson commentedQuick fix using a block
The blow code adds an image to a gallery but you can easily replace the types for your use case
Comment #13
yorguey31 commentedI ve used the simple static field to do that it's pretty nice for adding non editable text such as 'a href'.
pointing to url we want. My problem is that i wanted to use token to build the url but this field does not support it.
I ve done some modifications on it and it work well !!
unfortunately i'm not able to reverse that to community because i dont know anything about Git...
If someone want to add it, it will be nice.
Hopes taht will help !
Comment #14
Anonymous (not verified) commented@yorguey31
where do you put the attached code?
thanks in advance
Comment #15
hickimse commented#12 working
How can ı do
How do I make it
Comment #16
jiakomo commentedI use views to create a block in order to create links and I use a contextual filter in order to use the nid of the referenced node from the url.
Comment #17
rakesh.nimje84@gmail.com commentedAdd one field (as link) to the content type with link module and use token to set url. It's simple solution working in my case.
Comment #18
autopoietic commentedWas about to make a simple block module and saw #6.
Thanks @azuledu, thats really neat. I would like to see it incorporated into the entity reference prepopulate module personally.
Comment #19
apmsooner commentedThis is dead simple using context from view or panel.
In a view for example, you can use tokens from contextual filter like this:
<a href="/node/add/plan?field_client_reference=!1&destination=node/!1">Add Plan</a>- field_client_reference = the machine name of my entity reference field
- !1 = the token value for my contextual filter
no need for php or other module if this is all you need.
Comment #20
leramulina commentedrwilson0429
I used your recipe but instead leading to the page
node/add/node-gallery-item?node_gallery_ref_1=1176
the link leads me to the page
node/add/node_gallery_item?node_gallery_item=[nid]&&destination=node/1176
Can you tell me, please, where I could be wrong?
The code in text field is
There are
Arguments:id
Contextual filters
Content: Nid
When the filter value is NOT available
Display all results for the specified field
When the filter value IS available or a default is provided
Specify validation criteria
Validator:
Content
Content types:
Gallery
Thanks!
Comment #21
tonyoh commentedleramulina,
I also couldn'y get it working and had to put the name of my site ... ie the full path into $url.
www.mysite.com/node/add/node-gallery-item.......
Sorry I can't help further.
Comment #22
apmsooner commentedSet context to provide default value : content id from url
Comment #23
schifazl commented@leramulina I also had problems with this, but finally I checked "Use replacement tokens from the first row" under the text field and replaced [nid] with !1
I know that this is old, but maybe it could be useful for someone :)
Comment #24
paulwdru commentedAfter lengthy discussion for about 4 years, is maintainer aware of what's being critically missing in Entity Reference Prepopulate as compared to Node Reference URL Widget ? Thanks
Comment #25
alauddin commentedYes, its amazing we still dont have a module to do this after all this time.
here is a snippet of code that I use with Display Suite - Extras sub-module
1) enable module - than go to admin/structure/ds/list/extras
2) Check Enable Extra fields
3) create code field - admin/structure/ds/fields
3a) attach to 'node' entities
3b) filter if you want to only the content type that this field should display on
3c) field code: php filter
4) change link text
change node/add/xxx to your content type
change field_gallery_ref to your entity ref field found on the node you are creating.
5) Go to 'manage display' of your referenced content type and you should see the ds field...place it where you like and prosper :)