fruitstudios / linkit Goto Github PK
View Code? Open in Web Editor NEWMulti-purpose link plugin for Craft CMS
License: MIT License
Multi-purpose link plugin for Craft CMS
License: MIT License
I just realised that I'm at version 0.9.1 in this plugin. It would be nice I'f you could submit a update message in the Craft CP as other updates do…… Or am I so behind that this has already been implemented?
When linking to an entry, the {{ entry.linkItField.url }} results in empty output if the chosen entry has a future post date or is expired.
When creating an event listing or archive listing I would think it should still output the entry url.
I was able to get by for now with a hacky twig workaround for now by checking for the related entry's url, but this is really not ideal:
{{ entry.linkItField.entry.getUrl()|default(entry.linkItField.url) }}
Craft 2.6.2952, LinkIt 2.3.4
Thanks for the awesome plugin and all your hard work!
Hello,
I have a supertable with a matrix inside of it and a Linkit field inside the matrix and when it's outputted on the template it is not a FruitLinkIt_LinkModel
it's rendered as a Twig_Markup
, basically it's completely empty (even if a URL is entered) and does not have any of the advanced templating parameters.
Somewhere along the line the supertable + matrix combo makes the Linkit field lose it's field type object and get rendered as a non field field (basically without a class).
I've not found the cause yet.
I know this is a strange scenario, but in our case there's good reason... we have a LinkIt field set to link to a channel of entries, and then the field is assigned to the publishing layout of that channel. When editing an entry, and the LinkIt field opens up a modal to pick from entries in the channel, the existing entry is disabled and unavailable to select. Is that specifically by design, or just an inadvertent behaviour?
Looking at https://github.com/fruitstudios/LinkIt/blob/master/fruitlinkit/templates/_fieldtype/input.html, it looks like the select is supposed to go away, but there is always multiple things in the passed types
array because of the "Link To..." option.
I've got a LinkIt field currently in a Matrix, then inside a SuperTable. When I go to choose an entry it only shows the entries for 1 locale. Weirdly, this locale it shows entries for isn't the one we're currently in, editing the entry.
I tried creating just a standard LinkIt field to see if Matrix or SuperTable was causing the issue but creating a field on it's own doesn't work.
Is there meant to be locale options here:
Am I missing something? I did update from version 0.9.1 of Linkit if this is any help.
Thanks
Is it possible to only put the href? I would like to do something like the following:
<a href="{{ cat.link.linkItField }}" class="categories__item__cta">
Alternatively is it possible to add the element as a wrapper?
Something like this:
{{ linkItField.beginningHere }}
<div class="categories__item__background-wrapper">
<img src="http://unsplash.it/500/500" alt="" class="categories__item__background" />
</div>
<div class="categories__item__button"><span class="standard">{{ cat.titel }}</span><span class="hover">Meer info</span></div>
<div class="categories__item__overlay">
<h2 class="categories__item__overlay__title title--stroked title--stroked--center">{{ cat.titel }}</h2>
<div class="typography typography--light typography--14">
<p>{{ cat.inhoud }}</p>
</div>
</div>
{{ linkItField.endHere }}
Might it make sense to prevent selection of entries within sections that do not have URLs?
/**
* Returns all sections that have URLs.
*
* @return array An array of Section instances
*/
public function getSectionsWithUrls()
{
return array_filter(craft()->sections->allSections, function ($section) {
return $section->isHomepage() || $section->urlFormat;
});
}
I'm having trouble understanding how to use the linkit_getElementData
hook. Do you have an example plugin that uses it?
Specifically, I'm having trouble with the myPlugin_myElements
bit in $myElement = craft()->myPlugin_myElements->getMyElementById($id);
. Is myPlugin_myElements
supposed to be my plugin's name? In that case, should I be implementing my own public getMyElementById
method? Or how does it work? I keep running into Exceptions when I try to use it.
When trying to show the value of a linkit field in the entry list view a blank value is displayed instead of the value entered by the user, I tihnk it would be greatly beneficial if we added support for this.
Image for reference, the fields in the red box are LinkIt fields:
(In this case it is an email and a "phone" link)
Can you please provide translatable options for /templates/_fieldtype/input.html in a next version?
Some examples:
placeholder: settings.defaultText == '' ? 'Custom Link Text' : settings.defaultText,
and
label: 'Open link in new window?',
It would be nice to simply add the |t
function to make the values translatable:
label: 'Open link in new window?'|t,
Thanks in advance
link
is a reserved work so might be worth replacing the documentation.
This tripped me up when using SuperTable, which doesn’t validate handles (verbb/super-table#19).
Is it possible to link to categories? (can't seem to find any reference to this functionality). If not how hard is it to add it please? I'd be happy to help with it :)
It'd be great to have the plugin hooked up to a release feed to stay up to date with changes.
I'm wanting to pass custom html in as the link content when using the htmlLink() template method.
I know I could handle the link manually in the template, but it seems like a waste when the htmlLink method is set up to handle all the possible link types already.
From looking at the LinkModel it seems this isn't currently possible, but I may be missing something.
So yeah it would be nice to be able to set the "customText" value when accessing it via the template. Passing it as an "attributes" value seems like the simplest option to me, but perhaps that's not the most logical and maybe another public method for setting it would be better?
I'll probably hack a solution into the LinkModel for my current project, unless you have a simple solution that I'm missing?
Thanks
How would you go about the force download option? Is that something you could achieve with twig {% header %}
tags alone? I'm stumbling on how to include the raw contents of the file after the headers with twig...
{% header 'Content-Description: File Transfer' %}
{% header 'Content-Type: '~asset.mimetype %}
{% header 'Content-Disposition: attachment; filename='~asset.filename %}
{% header 'Content-Transfer-Encoding: binary' %}
{% header 'Expires: 0' %}
{% header 'Cache-Control: must-revalidate' %}
{% header 'Pragma: public' %}
{% header 'Content-Length: '.asset.size %}
{# Somehow print raw source of asset.filename #}
(Also, I swear I just stumbled upon this through a Google search, but so weird that we found each other's plugins on the same day and are each requesting features)
LinkIt is awesome, we all know that.
What would make it more awesome? The ability to extend it with hooks/events.
This way, I could write a plugin extending LinkIt's types
, say, specifically for handling YouTube/Vimeo/etc. urls. With that, I would be able to define how that changes the input when that type
is selected, as well as the default output on the template side.
Let me know if you're interested in adding this functionality, or if you'd be willing to accept a PR with something like this.
Thanks!
I am using Link It to output a URL for an image link but how do I output the target="_blank" for a link that I'm manually templating using the link URL? If it's not already built in somehow, I would love to be able to access entry.field.target and have it output _blank or _self based on what the user sets the option to.
Is the ability to link to commerce products on the horizon?
I proxy my local development environment through Codekit sometimes and I have a nav Structure outputting the main menu for me. My issue is that for entry links, the full URL is outputted. I would love a way to only output the "path" for the entry instead of the URL, otherwise when I click through my nav, it jumps me out of the proxy URL I use with Codekit and kicks me back to the main site URL. Hope that makes sense! :-)
I've added a field, but when referencing in twig it's returning null
, via {{ entry.cta }}
. The field exists, but values don't see to be accessible. here's an inspection of the field:
Attributes:
columnPrefix
context global
groupId 4
handle cta
id 45
instructions
name CTA
oldHandle
required
settings {"types":["custom","entry"],"defaultText":"","allowCustomText":"1","allowTarget":"1","entrySources":["singles","section:2","section:7","section:3"],"entrySelectionLabel":"Link to an page\/entry","assetSources":"*","assetSelectionLabel":"Link to an asset"}
translatable 1
type FruitLinkIt
Any ideas of what I might be missing? Thanks.
Update: I seem to be able to access the field in a matrix, but still not at entry root:
{% for action in entry.ctas %}
{{ action.cta|inspect }}
{% endfor %}
We added the new fruitlink plugin folder to the craft plugins folder. The database shows the migration ran however the old version wasn't removed and the previous linkit inputs weren't updated to the new version. Did we miss a step in the update process?
I added a LinkIt field with "custom Url" to my Entries, if i save the entry and the custom url is empty, the field claims: "Please enter a valid url". But the field is not marked as required.
Same problem if i choose "entry" link-type.
Getting template errors (Impossible to access an attribute ("url") on a boolean variable ("")) while using this tag on the second language on a localized site. In my case my-domain.nl/en/
<a href="{{ link.url }}" {{ link.target ? ' target="_blank"' }} title="{{ link.linkText }}"
class="tp-caption sfb skewtotop btn btn-link"
data-x="{{ block.linkXPosition}}"
data-y="{{ block.linkYPosition}}"
data-speed="1000"
data-start="2000"
data-easing="Power4.easeOut"
data-endspeed="400"
data-endeasing="Power1.easeIn">
{{ link.linkText }} <i class="fa fa-angle-right"></i>
</a>
It would be awesome if the plug-in allowed through an admin interface or a JSON config file for developers to add custom "custom URL" plain text links. For our use case it would be so we could rely on the same field to provide an asset OR a link to something like a SoundCloud track but it would expose that metadata as a link type - so that {{ entry.linkItField.type }} would return whatever the customized string would be.
I'm using the LinkIt field type for storing members custom URL's.
I want to allow members manage their custom URL's via the front-end in a profile update page.
Is it possible to edit LinkIt field values via the front-end?
Hi,
First of all, thank you for your plugin. It solves a common issue that Craft has.
The only drawback compared to the built-in "entries" field is that LinkIt does not allow to add more than one link. It would be nice is, as of the built-in entries, you could enforce a limit, but allow to add more than 1 link.
Thanks!
Are there any plans to support custom selection labels? Renaming from "Add an asset" to "Add an image" is a big help to UX.
Love the plugin. Thanks :)
Expected behviour is surely not to create links like this if http prefix is not there
https://lhaseylotsawa.org/admin/entries/practiceTexts/www.dharmasun.org/tte
when:
www.dharmasun.org/tte
is the custom link field contents.
Possible solutions would be to automatically add the prefix (preferably otherwise I'll have to go through the entries by hand to invoke the corrected validation) or not allow it to be saved without.
At the moment I'm adding this to the description of the field which is not ideal.
If linking to an external site please include the full URL ie. http://website.com/ and not simply website.com
It would be nice to have an option to append query string parameters and anchor names/ids to dynamically generated URLs (entries, assets etc.).
This is something, which popped-up on several projects and we don't have a solution yet.
This would be particularly useful for adding third party Element Types.
I can't get this to show the field if only one Link Type is selected, such as email.
I have made it work by adding the following code at line 23 of templates/_fieldtype/input.html:
{% else %}
{% if type is null %}
{% for key,value in types %}
{% set type = key %}
{% endfor %}
{% endif %}
<input type="hidden" name="{{ name }}[type]" value="{{ type }}" />
This sets the type to the only valid type in the types array and therefor allows the field to be used, however it doesn't let you save the field empty.
I may be mis-using the plugin here but I basically want it to just validate an email field in this scenario and am using it elsewhere so didn't want to install a different plugin for just that purpose.
Hi, thanks for this great plugin!
Just updated to the latest version and when clicking the "open in new window" checkbox and saving the entry, the option does not hold - i.e. entry.linkitfield.target is not set. Also when in the entry editor again, the checkbox will not be ticked.
Thanks in advance!
Dan
Current Install:
CraftCMS version: 2.6.2968
LinkIt version: 2.3.4
With this installed, and attempting to create or edit entries that use a LinkIt field type I am getting a internal server error of: Call to a member function getClassHandle() on null
The runtime logs show:
#17 /storage/av04327/www/craft/plugins/fruitlinkit/fieldtypes/FruitLinkItFieldType.php(136): Craft\TemplatesService->render('fruitlinkit/_fi...', Array)
#18 /storage/av04327/www/craft/app/vendor/twig/twig/lib/Twig/Template.php(615): Craft\FruitLinkItFieldType->getInputHtml('buttonLink', '')
Running LinkIt version 0.6 on Craft 2.1.2564. When trying to use any template variables (type, link, url, etc), I receive the following message (eg: url):
Impossible to access an attribute ("url") on a boolean variable ("")
I've tried using version 0.5 on Craft 2.1.2564 only to have the same result.
Running version 0.5 on Craft 2.0.2540 works fine.
Hi,
I'm having a issue with the following use case. I have LinkIt fields in a team members sections for optional external links to social media accounts. These are all optional and a number of the team members don't have social media accounts to link. However, it doesn't seem possible to save an entry even though the LinkIt field is not set to required.
Is there an alternative implementation for this use case?
I keep getting this error in the phperrors log when Craft is running it's re-save entries task. It appears thhis stops the task from completing.
Call to a member function getUrl() on a non-object in Linkit_LinkitFieldType.php on line 384.
I am running Craft Pro 2.2.2588.
Hey-
Noticed a small little bug. If an entry or asset is being linked to within linkit plugin and that element is deleted for whatever reason, rather than returning false or null it's throwing a php error.
On lines 381 & 396 (of the version I have at least) - you're doing a conditional to see if an ID is present. If you added an additional conditional to ensure the entry exists it'll fix the error & return the default fallback of false
Could you please take advantage of Craft's static translation support by running all text through "*|t" or Craft::t()? We see that some strings are translatable and other strings aren't.
Linkit is in English and we want to translate it to Dutch for a customer. Especially the select options (Email Address, Telephone Number, etc.) and field placeholders.
Thanks!
I'm getting an error ("Please enter a valid email address.") when entering a business email address into the email option for LinkIt. Does LinkIt's validation only validate standard email address (gmail, yahoo, etc.?) An example email address I'm trying to use is [email protected].
I'm not sure if this has been asked yet, or if perhaps I'm missing something.
I've noticed that if an entry status is changed to inactive, this will remove the entry from any associated LinkIt fields.
If I later on change that entry back to active, to restore the link, I have to return to any associated LinkIt fields, and relink to that entry.
It would be ideal if status changes did not remove the link association.
I have a site using a Structure section with a single Link It field for navigation. The field is called "navigationEntry" and links Entries, Assets and Categories. How can I get it to go breadcrumbs? It does not seem to work with relationships so how can I get this code below to work? It does not really output anything. What am I missing?
{% set bread = craft.entries.section('mainNavigation').relatedTo(entry.navigationEntry.entry).first %}
<nav class="breadcrubs">
<ol class="breadcrumb">
<li><a href="{{ siteUrl }}">Home</a></li>
{% for crumb in bread.getAncestors %}
<li>{{ crumb.navigationEntry.html }}</li>
{% endfor %}
<li>{{ bread.title }}</li>
</ol>
</nav>
I think since the latest update the value of linkItField.text
defaults to linkItField.url
if no custom text is provided. I used to check if a text is provided to alter my html output.
Is this intended? Is there a way to check if there is a custom text provided?
Hi,
I'm attempting to create a navigation list using entries with a linkit field. Here is the template code I'm using:
{% set nav_entries = craft.entries.section('primaryNavigation').find() %}
<ul id="primary-nav">
{% nav entry in nav_entries %}
<li>
{% set link = entry.navLink %}
{% switch link.type %}
{% case "entry" %}
<a href="{{ link.entry.url }}" {{ link.target ? ' target="_blank"' }} title="{{ entry.title }}">{{ entry.title }}</a>
{% case "asset" %}
<a href="{{ link.asset.url }}" {{ link.target ? ' target="_blank"' }} title="{{ entry.title }}">{{ entry.title }}</a>
{% case "custom" %}
<a href="{{ link.custom }}" {{ link.target ? ' target="_blank"' }} title="{{ entry.title }}">{{ entry.title }}</a>
{% case "email" %}
<a href="mailto:{{ link.email }}" title="{{ entry.title }}">{{ entry.title }}</a></p>
{% case "tel" %}
<a href="tel:{{ link.tel }}" title="{{ entry.title }}">{{ entry.title }}</a></p>
{% endswitch %}
{% ifchildren %}
<ul>
{% children %}
</ul>
{% endifchildren %}
</li>
{% endnav %}
</ul><!-- /#primary-nav -->
And I'm receiving the Twig error: "Impossible to access an attribute ("type") on a boolean variable ("")", highlighting the line "{% switch link.type %}".
Am I missing something? Could this be a compatibility issue with Craft 2.0?
Thanks! Looks like a great plugin by the way, if I can get it to work.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.