How to change viewer urls
9 posts by 2 authors in: Forums > CMS Builder
Last Post: December 22, 2007 (RSS)
By Djulia - December 20, 2007 - edited: December 22, 2007
Thank you for your update. It functions perfectly. [:)]
I have another remark.
Article Manager has an important option.
It makes it possible to give a name different from the title to the file.
For example :
Menu Name?Filename
instead of :
Menu Name?Title
It will be possible to add this option ?
Thank you for your answer.
Djulia
Re: [Djulia] Add or Upload File(s)
By Dave - December 20, 2007
In your "List Viewer" page search for 'titleField', like this:
$options['titleField'] = 'title';
// (optional) MySQL fieldname used in viewer url for search engines.
// Example: 'title' would display: viewer.php/article_title_here-123
Just change "title" to whatever fieldname you want output in your urls (or even create a new "filename" field for that if you like) and it will update all your links.
Let me know if that works for you. :)
interactivetools.com
Re: [Dave] Add or Upload File(s)
By Djulia - December 22, 2007
Thank you, it is perfect. [:)]
It would be possible to obtain the value of Title in my new fields ?
Such as for example for the fields Field Label and Field Name in Section Editors.
It is a code Javascript which it is necessary to use ?
Thank,
Djulia
Re: [Djulia] Add or Upload File(s)
By Dave - December 22, 2007
Typically when you add a field you can display it with some PHP code like this: <?php echo $record['fieldname'] ?>
So if you add a field called 'title' or 'urlKeywords' you could display them like this: <?php echo $record['title'] ?> or <?php echo $record['urlkeywords'] ?>
If you could explain in a little more detail what you want to do, I'll try and give you a better answer.
interactivetools.com
Re: [Dave] Add or Upload File(s)
By Djulia - December 22, 2007
Thank you for your answer.
I have Title field and Filename field.
I would like to use the function "autoFillQuickAddFieldName" to convert the characters in Filename (field).
<INPUT id=fieldTitle onkeyup=autoFillQuickAddFieldName() onchange=autoFillQuickAddFieldName() name=fieldFilename>
<INPUT id=fieldname name=fieldname>
But that seems difficult, because the fields on the page are built dynamically, not ?
Thank,
Djulia
Re: [Djulia] Add or Upload File(s)
By Dave - December 22, 2007
No, unfortunately there's no easy way to do that right now.
What if we updated the List Viewer so you can specify multiple fields for the 'titleField' option, and it used the first non-blank one for the url. That way you could specify:
$options['titleField'] = 'fieldname,title';
And if the filename was specified it would use that in the url, otherwise it would use the title in the url.
Would that do what you want?
interactivetools.com
Re: [Djulia] Add or Upload File(s)
By Dave - December 22, 2007
Open up /lib/viewer_functions.php and search for "$options['titleField']"
Find this block of code:
if (@$options['titleField']) {
$extraUrlDetails = "";
if (!array_key_exists($options['titleField'], $record)) {
$extraUrlDetails = "Unknown_fieldname_specified_for_titleField_option/";
}
else {
$extraUrlDetails = preg_replace('/[^a-z0-9\.\-\_]+/i', '_', @$record[$options['titleField']]);
if ($extraUrlDetails) { $extraUrlDetails .= "-"; }
}
}
$record['_link'] = $options['viewerUrl'] . $urlDelimiter . $extraUrlDetails . $record['num'];
Replace it with this block of code (note that the first and last lines don't change):
if (@$options['titleField']) {
foreach (preg_split("/\s*,\s*/", $options['titleField']) as $fieldname) {
if (!array_key_exists($fieldname, $record)) {
die("$viewerName: Unknown field '" .htmlspecialchars($fieldname). "' in titleField options!");
}
if ($extraUrlDetails == "" && $record[$fieldname] != "") {
$extraUrlDetails = preg_replace('/[^a-z0-9\.\-\_]+/i', '_', "{$record[$fieldname]}-");
}
}
}
$record['_link'] = $options['viewerUrl'] . $urlDelimiter . $extraUrlDetails . $record['num'];
Once you've done that, you can specify multiple fieldnames in the 'titleField' option and the first defined field will be used. Like this:
$options['titleField'] = 'filename,title';
Hope that helps! :)
interactivetools.com
Re: [Dave] Add or Upload File(s)
By Djulia - December 22, 2007 - edited: December 22, 2007
Your code works correctly. [:)]
Thank you for your assistance. :)
Djulia