Diff patch from a single file? - diff

I'm looking at a diff patch file provided by Magento and it looks something like this:
--- downloader/Maged/Controller.php
+++ downloader/Maged/Controller.php
## -1017,7 +1017,7 ## final class Maged_Controller
'major' => '1',
'minor' => '14',
'revision' => '0',
- 'patch' => '0',
+ 'patch' => '1',
'stability' => '',
'number' => '',
);
look at the first two lines - how did they do that? shouldn't source and target be different?

I managed to do this using SVN's create patch functionality.

Related

TYPO3 9.5: TCA type 'slug' always adds '-1' to URL

I have the following configuration in my extbase TCA configuration:
'path_segment' => array(
'exclude' => 1,
'l10n_mode' => 'mergeIfNotBlank',
'label' => 'Path Segment',
'config' => [
'type' => 'slug',
'generatorOptions' => [
'fields' => ['productname'],
'replacements' => [
'/' => '-',
'.' => '',
'®' => '',
',' => '',
'|' => '',
' ' => '-',
],
],
'fallbackCharacter' => '-',
'eval' => 'unique'
]
),
When I save, I get URLs with -1 added to the URL (f.e.g "myproduct-1" instead of just "myproduct")
I can only avoid this when clicking the Icon which is labled "Recalculate URL Segment from page title" in the List-Module when editing a record.
Our Editors do not mind much about this field and would change the URL every time they save the record.
What can I do to have this "recalculation" automatically" done? Or what am I doing wrong in my configuration?
I'm using TYPO 3 9.5.17.
You should update to 9.5.18. This behaviour is a regression:
2020-05-14 ccd6da5027 [BUGFIX] Exclude current record when checking slug's uniqueness (thanks to Xavier Perseguers)
See Release Notes.

TYPO3 Realurl Configuration Category Page

I have TYPO3 7.6.10.
I have tx_news.
I want to configure my page with news by category.
Now i have:
'newsCategoryConfiguration' => array(
array(
'GETvar' => 'tx_news_pi1[overwriteDemand][categories]',
'lookUpTable' => array(
'table' => 'sys_category',
'id_field' => 'uid',
'alias_field' => 'title',
'addWhereClause' => ' AND NOT deleted',
'useUniqueCache' => 1,
'useUniqueCache_conf' => array(
'strtolower' => 1,
'spaceCharacter' => '-'
)
)
)
),
It works and the result is:
/domain/page-With-List-Of-News-By-Category/Category
If have a sub category the result is:
/domain/-page-With-List-Of-News-By-Category/Category
Ho can i get:
/domain/page-With-List-Of-News-By-Category/Parent-Category/Sub-Category
Maybe there's a faster or better way. But if you won't find, try this and build it yourself using userfunc in that way:
'useUniqueCache_conf' => [
'strtolower' => 1,
'spaceCharacter' => '-',
'encodeTitle_userProc' => 'My\Ext\Hooks\News\RealUrlCategories->buildCategoryPath'
];
and the class something like:
class RealUrlCategories {
function buildCategoryPath($parameters) {
$categoriesPath = '';
// find category rootline
// you can find the uid somewhere in $parameters, then iterate for parent categories and read db for the titles to build final string
...
// return generated string like "Parent-Category/Sub-Category"
return $categoriesPath;
}
}
The problem is, that realURL parses the result of the userFunc with rawurlencode. So Parent-Category/Sub-Category would be transformed to Parent-Category%252FSub-Category.
You could return Parent-Category-Sub-Category. This would also be stored in the cache.
Also your UserFunc could return Parent-Category~~~Sub-Category and you replace the ~~~ with a / in a $GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['realurl']['encodeSpURL_postProc'] hook, but the ~~~ will be stored in the cache.
You could also add another parameter like parent_category, but this optional parameter doesn't work in the fixesPostVars section because here the parameter is required and so if it is empty, you have an double slash //category in your URL.
Could you find any other solution beside to use the format parent-category-sub-category?

Multiple Values in RealUrl

When I got multiple values in my URL of the same name
e.g …&tx_myext_pi1[crit][]=1&tx_myext_pi1[crit][]=2…
and I want to have it multiple times in my RealUrl-ified URL
like …/crit/title-of-crit-1/crit/title-of-crit-2…
it's not working.
I only get …/crit/title-of-crit-1… and …/crit/title-of-crit-2… is missing
…&tx_myext_pi1[crit][]=1…
translates to …/crit/title-of-crit-1/… and
…&tx_myext_pi1[crit][]=2…
translates to …/crit/title-of-crit-2/…
so that part is working. But not multiple values.
Is this impossible to do with RealUrl?
Should I make a userFunc? How?
My RealUrl Conf
// …
'postVarSets' => array(
'_DEFAULT' => array(
'crit' => array(
array(
'GETvar' => 'tx_myext_pi1[crit][]',
'lookUpTable' => array(
'table' => 'tx_myext_domain_model_crit',
'id_field' => 'uid',
'alias_field' => 'title',
'languageGetVar' => 'L',
'languageExceptionUids' => '',
'languageField' => 'sys_language_uid',
'transOrigPointerField' => 'l10n_parent',
'autoUpdate' => 1,
),
),
),
),
// …
Is this impossible to do with RealUrl?
Yes, is impossible to achieve this using RealUrl.
The problem is that you are using array in the query string.
You can merge your values in one string
Like this:
/crit/title-of-crit-1,title-of-crit-1
Or
/crit/title-of-crit-1+title-of-crit-1
And split it when you need. by , Or + or another special character.
For example Drupal uses this rule for multiple values in views moudle.

CakePHP Form Dropdown

I've got this table in my database that outputs this:
array(
(int) 0 => array(
'Price' => array(
'id' => '1',
'amount' => '20',
'price' => '180.00',
'type_id' => '1',
'active' => 'a'
)
),
(int) 1 => array(
'Price' => array(
'id' => '2',
'amount' => '30',
'price' => '232.50',
'type_id' => '1',
'active' => 'a'
)
),
...And so on.
I need a drop down in my form that displays the amount and price together (ie. "20 # 180.00"), but when selected, gets the "id" field.
I reworked a new array called $prices so it outputs like so...
array(
(int) 0 => array(
'id' => '1',
'amount' => '20',
'price' => '180.00',
'type_id' => '1',
'active' => 'a',
'display' => '20 # 180.00'
),
(int) 1 => array(
'id' => '2',
'amount' => '30',
'price' => '232.50',
'type_id' => '1',
'active' => 'a',
'display' => '30 # 232.50'
However, I'm not sure if that array is necessary.
But the main problem is that I don't know what to put in the Form options to make it select the "display" field.
echo $this->Form->input('Project.quantity', array(
'options' => $prices[?????]['display']
));
Simply adding the
'options' => $prices
displays a lot of stuff in the drop down (http://f.cl.ly/items/1e0X0m0D1f1c2o3K1n3h/Screen%20Shot%202013-05-08%20at%201.13.48%20PM.png).
Is there a better way of doing this?
You can use virtual fields.
In your model:
public $virtualFields = array(
'display' => 'CONCAT(amount, " # ", price)'
);
In the controller:
$prices = $this->Price->find('list', array(
'fields' => array('id', 'display')
));
Two ways to do this.
You said you reworked you array to $prices. Then, change that rework so the $prices array looks like this
array('1' => '4 # 6',
/*id*/ => /*price*/
/*etc*/);
and then pass it to the form
echo $this->Form->input('Project.quantity', array(
'options' => $prices
));
For a simple dropdown, retrieve the data with a find('list'). That will give you an array like the one you need to make a dropdown. To change the display field, create a virtual field like this in the model
public $virtualFields = array("display_price"=>"CONCAT(amount, ' # ' ,price)");
public $displayField = 'display_price';
And that way you don't have to rework your array.
If you have other drowpdowns of the same model in other forms, note that those will also change. That's the advantage of doing that in the model... Or disadvantage, if you only want to do it in one part... Like almost everything, it depends on what your need are :)

realurl in typo3

I'm working on a website that is made in typo3. I'm doing a part of the website that is made by somebody else, so I don't know that much of typo3.
This website uses realurl to translate the url to a readable one. How can I make a realurl? When I make like for example the index page there is no realurl made for this page. How could I generate one?
First of all, check the manual of realurl :
http://typo3.org/extensions/repository/view/realurl/current/
http://typo3.org/documentation/document-library/extension-manuals/realurl/1.10.2/view/
Check if RealUrl is enabled via TypoScript.
Check if links are generated with TYPO3 API / TypoScript.
Use RealUrl configurators
http://typo3.org/extensions/repository/view/cbrealurl/current/
Dmitry got more relevant tutorials about RealURL:
http://www.dmitry-dulepov.com/2008/05/realurl-made-easy-part-1.html
http://www.dmitry-dulepov.com/2008/06/realurl-made-easy-part-2.html
RealURL will be very easy to understand when you'll make it work with default configuration and understand the meaning of parts: 'init', 'preVars', 'postVarSets', 'pagePath', 'fixedPostVars' and 'fileName'.
Copy my configuration
typoscript in setup:
config.simulateStaticDocuments = 0
config.baseURL = /
config.tx_realurl_enable = 1
config.uniqueLinkVars = 1
config.absRefPrefix = http://www.ceisufro.cl/
page.config.language = cl
config.sys_language_uid= 0
config.useSysLanguageTitle = 1
config.language= es
config.language_alt= es
config.htmlTag_langKey= es
config.linkVars = L
config.sys_language_overlay = 1
config.htmlTag_setParams = xmlns="http://www.w3.org/1999/xhtml"
xml:lang="es" lang="es"*
In file localconf.php
$TYPO3_CONF_VARS['EXTCONF']['realurl'] = array(
'www.ceisufro.cl'=> array(
'init' => array (
'enableCHashCache' => '1',
'appendMissingSlash' => 'ifNotFile',
'enableUrlDecodeCache' => '1',
'enableUrlEncodeCache' => '1',
),
'redirects' => array (
),
'preVars' => array(
'0' => array(
'GETvar' => 'L',
'valueMap' => array(
'es' => '1',
'en' => '0',
'it' => '4',
),
'noMatch' => 'bypass',
'valueDefault' => 'es',
),
),
'fileName' => array(
'defaultToHTMLsuffixOnPrev' => '1',
),
'pagePath' => array(
'type' => 'user',
'userFunc' => 'EXT:realurl/class.tx_realurl_advanced.php:&tx_realurl_advanced->main',
'spaceCharacter' => '-',
'languageGetVar' => 'L',
'expireDays' => '3',
'rootpage_id' => '1',
), 'fileName' => array (
'index' => array (
'rss.xml' => array (
'keyValues' => array (
'type' => '100',
'id' => '37'
),
),
'contacto.xml' => array (
'keyValues' => array (
'id' => '666',
'no_cache'=>'1'
),
),
)),
'fixedPostVars' => array(
),
),
);
go to ext manager, find the ext realurl and add the following configurations
check Enable automatic configuration
select Serializable in Automatic configuration file format
check Enable devLog
I wait to can help somebody