This question has been answered by fgarydc. See the first response.
If the links are uniform enough, you could do it with a utility snippet using preg_replace(), but it would take some careful testing.
Can you give a few examples of the links?
Also, where are the links (resources, templates, chunks, tvValues, etc.)?
If the links are uniform enough, you could do it with a utility snippet using preg_replace(), but it would take some careful testing.
Can you give a few examples of the links?
Also, where are the links (resources, templates, chunks, tvValues, etc.)?
<?php $tvId = 12; // IMPORTANT: change this to the ID of your Art Image TV. $tvrs = $modx->getCollection('modTemplateVarResource', array('tmplvarid' => $tvId)); $count = 0; foreach($tvrs as $tvr) { $value = $tvr->get('value'); $value = str_replace('http', 'https', $value); $tvr->set('value', $value); $tvr->save(); $count++; } return "<h3>Fixed " . $count . ' TVs</h3>';
Having them in a TV value makes it much easier. Just put this tag on a page:
[[!convertHttp]]
Then create a snippet called convertHttp, with this code (untested):
<!--?php $tvId = 12; // IMPORTANT: change this to the ID of your Art Image TV. $tvrs = $modx--->getCollection('modTemplateVarResource', array('tmplvarid' => $tvId)); $count = 0; foreach($tvrs as $tvr) { $value = $tvr->get('value'); $value = str_replace('http', 'https', $value); $tvr->set('value', $value); $tvr->save(); $count++; } return "<h3>Fixed " . $count . ' TVs</h3>';
(Be sure to change the $tvId variable value in the code above. The TV's ID is shown in parentheses in the Template Variable tree in the Manager.)
Then, visit the page with the tag on it and you should be in business.
This assumes that there are no values of Art Image TVs with http that you don't want to convert.
Quote from: BobRay at Jul 08, 2017, 04:05 AMHaving them in a TV value makes it much easier. Just put this tag on a page:
[[!convertHttp]]
Then create a snippet called convertHttp, with this code (untested):
<!--?php $tvId = 12; // IMPORTANT: change this to the ID of your Art Image TV. $tvrs = $modx--->getCollection('modTemplateVarResource', array('tmplvarid' => $tvId)); $count = 0; foreach($tvrs as $tvr) { $value = $tvr->get('value'); $value = str_replace('http', 'https', $value); $tvr->set('value', $value); $tvr->save(); $count++; } return "<h3>Fixed " . $count . ' TVs</h3>';
(Be sure to change the $tvId variable value in the code above. The TV's ID is shown in parentheses in the Template Variable tree in the Manager.)
Then, visit the page with the tag on it and you should be in business.
This assumes that there are no values of Art Image TVs with http that you don't want to convert.
Almost works. The code is replacing http with httpsssssss. Do you know why?