thecogworks / cogworks.findandreplace Goto Github PK
View Code? Open in Web Editor NEWA simple and intuitive package which allows editors to find and replace content in Umbraco 7.
License: MIT License
A simple and intuitive package which allows editors to find and replace content in Umbraco 7.
License: MIT License
Functionality may help to deal with multiple nodes named exactly the same and living in the different places in the content tree. It should help editors to decide which one should be replaced and which not.
The Find & Replace tool is really nice and simple to use, but isn't restricted to specific users. This means that, theoretically, any Umbraco user could change content across the site unchecked. Is it possible for the tool to be locked down based on user permissions?
My stakeholders really like the simplicity of the tool and the fact that they can choose which documents to apply a change to rather than just applying it to all. However, they were disappointed at the lack of a multi-select option - so while they might not want to apply a change to all documents, they might want to apply it to quite a lot, but without having to apply one at a time. Would this be possible to include?
Thanks!
This is just a placeholder since I started working with the code (the find sql statement in particular) in this package and Umbraco v12. I found that, when running locally using SqlLite that the nested JOIN statements results in a syntax error from SqlLite. The docs seem to indicate nested JOINS are supported...but not for me. I reworked the sql in Cogworks.FindAndReplace.Web.API.FindPhrase
to flatten the JOINS.
I also noted that SqlLite report that [umbracoDocumentVersion].[id]
does not exist...it clearly does...so that is commented out. When left in the SqlLite compiler returns this error message:
Error while executing SQL query on database 'Umbraco.sqlite': no such column: umbracoDocumentVersion.id
The current sql statement that works as expected with v12 and SqlLite is:
SELECT
[upd].[varcharValue] AS [VarcharValue],
[upd].[textValue] AS [TextValue],
[cv].[id] AS [VersionId],
[pcv].[text] AS [NodeName],
[upt].[Alias] AS [PropertyAlias],
[upt].[Name] AS [PropertyName]
FROM [umbracoDocument]
INNER JOIN [umbracoContent] ON [umbracoContent].[nodeId] = [umbracoDocument].[nodeId]
INNER JOIN [umbracoNode] ON [umbracoNode].[id] = [umbracoContent].[nodeId]
INNER JOIN [umbracoContentVersion] [cv] ON [cv].[nodeId] = [umbracoDocument].[nodeId]
--INNER JOIN [umbracoDocumentVersion] [dv] ON [umbracoDocumentVersion].[id] = [cv].[id]
LEFT JOIN [umbracoContentVersion] [pcv] ON [pcv].[nodeId] = [umbracoDocument].[nodeId]
INNER JOIN [umbracoDocumentVersion] [pdv] ON [pdv].[id] = [pcv].[id] AND [pdv].[published] = 1
LEFT JOIN [umbracoContentVersionCultureVariation] [ccv] ON [cv].[id] = [ccv].[versionId]
--INNER JOIN [umbracoLanguage] [lang] ON [lang].[id] = [ccv].[languageId] AND [lang].[languageISOCode] = 'en-US'
INNER JOIN [umbracoPropertyData] [upd] ON [upd].[versionId] = [cv].[id]
INNER JOIN [cmsPropertyType] [upt] ON [upt].[id] = [upd].[propertyTypeId]
WHERE ([cv].[current] = 1)
AND ([umbracoDocument].[published] = 1)
AND ([umbracoNode].[path] LIKE upper('%YOUR HOME NODE ID%'))
AND
(
(
[upd].[textValue] is not null AND [upd].[textValue] LIKE '%YOUR SEARCH TERM%'
)
OR
(
[upd].[varcharValue] is not null AND [upd].[varcharValue] LIKE '%YOUR SEARCH TERM%'
)
)
ORDER BY ([umbracoDocument].[nodeId])
I should note that I did not try the sql with SqlServer (any version) so the issues I noted may not exist for that RDBMS.
I've added the 8.x package to my Umbracxo 8.5.3. site, I've updated the source solution to 8.5.3. as well and ran into two issues.
The first is that in the FindAndReplaceApiController->content.SetValue(command.PropertyAlias, command.Value); is called without providing the culture which causes issues on amultilingual site (not sure if this still works if you site has 1 language.
Solution is ease:
In UpdateCommand add -> public string Culture { get; set; }
In FindAndReplaceApiController use -> content.SetValue(command.PropertyAlias, command.Value, command.Culture);
In FindAndReplaceservice.js you need to fill this value (it's supplied on the querystring):
FindAndReplaceService.$inject = ['$http', '$routeParams', 'umbRequestHelper'];
function setValue(contentId, propertyAlias, valueField, value) {
var config = {
PropertyAlias: propertyAlias,
VersionId: contentId,
**_Culture: $routeParams.mculture,_**
Value: value
};
.....................
}
The issue I had which I couldn't solve is that if the replacement terms ends with spaces, they are stripped off. There no trim() in the code so I suspect that this is something that AngularJS does unwanted. Any solution to this is also much appreciated ...
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.