TYPO3 extend flexform find not file - typo3-8.x

I would like to expand an extension while changing the flexform. However, I cannot get access to my Flexform.
call_user_func(
function($extKey) {
$GLOBALS['TCA']['tt_content']['types']['list']['subtypes_addlist']['test_pi1'] = 'pi_flexform';
\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addPiFlexFormValue('test_pi1','FILE:EXT:test2/Configuration/FlexForm/test.xml');
})
What's wrong with it?
The file is not flawed because I changed a text entry to see if it works.

what is the correct $_EXTKEY for your extension? Try
$pluginSignature = str_replace('_', '', $_EXTKEY) . '_pi1';
$GLOBALS['TCA']['tt_content']['types']['list']['subtypes_addlist'][$pluginSignature] = 'pi_flexform';
\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addPiFlexFormValue($pluginSignature, 'FILE:EXT:' . $_EXTKEY . '/Configuration/FlexForm/test.xml');

Related

SQLite: isolating the file extension from a path

I need to isolate the file extension from a path in SQLite. I've read the post here (SQLite: How to select part of string?), which gets 99% there.
However, the solution:
select distinct replace(column_name, rtrim(column_name, replace(column_name, '.', '' ) ), '') from table_name;
fails if a file has no extension (i.e. no '.' in the filename), for which it should return an empty string. Is there any way to trap this please?
Note the filename in this context is the bit after the final '\'- it shouldn't be searching for'.'s in the full path, as it does at moment too.
I think it should be possible to do it using further nested rtrims and replaces.
Thanks. Yes, you can do it like this:
1) create a scalar function called "extension" in QtScript in SQLiteStudio
2) The code is as follows:
if ( arguments[0].substring(arguments[0].lastIndexOf('\u005C')).lastIndexOf('.') == -1 )
{
return ("");
}
else
{
return arguments[0].substring(arguments[0].lastIndexOf('.'));
}
3) Then, in the SQL query editor you can use
select distinct extension(PATH) from DATA
... to itemise the distinct file extensions from the column called PATH in the table called DATA.
Note that the PATH field must contain a backslash ('\') in this implementation - i.e. it must be a full path.

Static content before loop

Am new to XQuery. I have written below query which is working perfectly and producing results in csv format from an
xml stored in Marklogic.
xquery version "0.9-ml"
let $data := someQuery
return
for $i in $data
return
fn:string-join((
$i/PATHTOFILED_1/text(),
$i/PATHTOFILED_2/text(),
.
.
.
.
$i/PATHTOFILED_N/text()
),","
)
Output:
abc,def,adc,
dff,eef,ddf,
.
.
.
.
fff,eed,ddg,
I have a new requirement to add static headers before the data.
And the expected output will be like
Expected Output:
HEAD1, HEAD2, HEAD3,
abc,def,adc,
dff,eef,ddf,
.
.
.
.
fff,eed,ddg,
Just adding HEAD1, HEAD2, HEAD3, in the top row. The headers are not part of the XML. They should be part of query in simple Strings with static data and can be modified at anytime in query itself.
I have tried to add the below code segment to the query. But the query is not running in Marklogic query console.
concat("HEAD1,"HEAD2","HEAD3"),
Any solution is highly appreciated.
Thanks in advance.
Add it before the FLWOR expression:
xquery version "1.0-ml";
string-join(("HEAD1","HEAD2","HEAD3"),","),
let $data := someQuery
return
for $i in $data
return
fn:string-join((
$i/PATHTOFILED_1/text(),
$i/PATHTOFILED_2/text(),
.
.
.
.
$i/PATHTOFILED_N/text()
),","
)
BTW, I really wouldn't use to 0.9-ml dialect unless you have a very compelling reason to do so. It works, but it is really only still there for compatibility.

How can i replace url from css

I'm trying to combine multiple css files into a single file (from many different folder in my host, and including external css files). I use the following short code:
Declare array:
$styles=array(
array(
'name'=>'style1.css',
'path'=>'http://mydomain.com/css/'
),
array(
'name'=>'camera.css',
'path'=>'http://mydomain.com/js/camera/'
),
array(
'name'=>'style3.css',
'path'=>'http://external.com/assets/css/'
));
Get content and replace url:
foreach ($styles as $style) {
echo preg_replace('/url\(\s*[\'"]?\/?(.+?)[\'"]?\s*\)/i', 'url('.$style['path'].'$1)', file_get_contents($style['path'].$style['name']));
}
After combined into one css file, i have some css background image url as follows:
url(ttp://mydomain.com/css/../image/background.png) //Internal path - Case 1A
url(http://mydomain.com/js/camera/../../image/background.png) //Internal path - Case 1B
url(http://external.com/assets/css/../../image/background.png) //External path - Case 2
Actual, the internal path (Case 1A, 1B) can display the background image (despite the lack of professionalism), but in the external path (Case 2) cannot display the background image, my question is:
How can i replace wrong path with correct path (REPAIR BASE ON CURRENT RESULTS) as:
url(http://mydomain.com/image/background.png) //Correct internal path
url(http://external.com/image/background.png) //Correct external path
(I understand the problem is if find a keyword containing '../' will remove keyword and remove 1 string before the keyword contain '*/', , but I can't figure out how to do this).
Thanks in advance.
(I have tried find out and tried searching for 1 week before ask new question).
additionally replace /up-level-directory/../ with /
that is '/([^\/]+)/../' with / globally
$correct_url = preg_replace('|/\w+/\.\./|', '/', $url);

Remove .js file works but a warning persist

i would like to remove a .js file from a drupal module to override this .js one in my theme.
So, in my MYTHEME_preprocess_page() function I added the following code:
//Delete logintoboggan.js and replace by our own in .info file
$tmpJs = drupal_add_js();
if (isset($tmpJs['module']['sites/all/modules/logintoboggan/logintoboggan.js'])) unset($tmpJs['module']['sites/all/modules/logintoboggan/logintoboggan.js']);
$vars['scripts'] = drupal_get_js($tmpJs);
This for, but a warning message appear on the website:
warning: Illegal offset type in isset or empty in /home/mykitxen/public_html/example.com/includes/common.inc on line 2210.
What is wrong?
You're missing the first parameter of drupal_get_js() ($scope), which should be 'header' or NULL in your case (with NULL just triggering the default 'header'). So the last line of your code should be:
$vars['scripts'] = drupal_get_js('header', $tmpJs);
or
$vars['scripts'] = drupal_get_js(NULL, $tmpJs);
NOTE: This assumes Drupal 6. If you are using Drupal 7, you might want to take a look at hook_js_alter().

Update configSource of XML element in web.config using Powershell by passing in Parameters

I am trying to figure out a way to update my web.config for different environments by updating the configSource for the appSettings element in the web.config.
Here are the way I know how to do it.
$xml.get_DocumentElement().appSettings.configSource = $replaced_test
The problem is that I want one base script where I can pass in different nodes to the script that I want to change and update but I am not sure how to do it.
For example, I want to be able to call a powershell script like this
changeWebConfig.ps1 nodeToChange newValueofNode
I hope this was clear enough.
This is the code I have now.
$webConfigPath = "C:\web.config"
# Get the content of the config file and cast it to XML
$xml = [xml](get-content $webConfigPath)
#this was the trick I had been looking for
$root = $xml.get_DocumentElement()."system.serviceModel".client.configSource = $replace
# Save it
$xml.Save($webConfigPath)
The problem I was having was the configuration node
I had to change it from
<configuration xmlns="http://schemas.microsoft.com/.NetConfiguration/v2.0">
this to
<configuration>
I am not sure how to find the node with the configuration node in it's orginal state yet, but I'm getting closer.
function Set-ConfigAppSetting
([string]$PathToConfig=$(throw 'Configuration file is required'),
[string]$Key = $(throw 'No Key Specified'),
[string]$Value = $(throw 'No Value Specified'))
{
if (Test-Path $PathToConfig)
{
$x = [xml] (type $PathToConfig)
$node = $x.SelectSingleNode("//client[#configSource]")
$node.configSource = $Value
$x.Save($PathToConfig)
}
}
set-configappsetting "c:\web.config" CurrentTaxYear ".\private$\dinnernoworders" -confirm
Finally figured it out.
$root = $xml.get_DocumentElement().SelectSingleNode("//client[#configSource]").configSource = "test"
of course, I will replace "//client[#configSource]" with a variable so I can pass in different nodes as parameters to create my base script.
Im looking for a way to modify the code as well.
Here is a way you can view whats the node:
$path = 'c:\site\web.config'
$PublishState = (Select-Xml -Path $path -XPath "configuration/appSettings/add[#key='PublishState']/#value").Node.'#text'
$PublishState

Resources