| Joomla - Editing "Advanced Attribs" from Front end |
|
I have run into a project that requires attaching some addition "Advanced" attributes to Joomla articles. I have extended the "blog category" menu type to incorporate jQuery to display the blog category with the titles as vertical tabs, and the introtext displayed in a content div when each tab is clicked. Articles selected for this vertical tabbed menu will also have an associated "menu image" and a "video file". The menu image will be a thumbnail that gets displayed in the tab, and the video file will be a flv video that is used to populate (using javascript) a fixed video player that will appear in another module position on the website. Note - this requires hacking a few Joomla core files. This coding was done on a Joomla 1.5.14 install. Joomal updates may break this code, depending on what gets updated. After installing these hacks, I would recommend making a backup of the modified files in case future Joomla upgrades overwrite these changes. Disclaimer: Use this code at your own risk - I am not responsible for any breakage of your Joomla website. First, to add the items in the "Parameters (Advanced)" area of the back end edit page, some tweaks need to be made to the file administrator/components/com_content/models/article.xml. As always, make sure to make a backup of all files before editing them. Locate the line : <params group="advanced"> and right below it add : <param name="article_image" type="imagelist" directory="/images/stories/thumbs" default="" label="Menu Image" description="Select the image to appear in the menu" /> Each <param> line should appear on a single line. Here is what the options mean: name="article_image" type="imagelist" default="" label="Menu Image" description="Select the image to appear in the menu" The website owner will need to manage all the content from the frontend - so we also need to place a modified copy of article.xml in components/com_content/models/. For this copy of the file, you can delete the first and last <params> block, just leaving the "advanced" group. Now, for the front end, I don't want the site owner to make changes to anything but the 2 new fields, so I change each "type" field to "hidden". The values will still get set and appear as hidden form fields. If you want the site owner to be able to toggle on things like the print icon, email icon, etc ... you can leave those be. The next step requires setting up a template override. You will need to place a copy of components/com_content/views/article/tmpl/form.php in templates/--yourtemplate--/html/com_content/article/ (create the directory if it does no <?php // preload the current article values //dump it to the screen Now, if you open a page in the front end edit mode, you should see the additional parameters down below the Meta tags and keywords. The real problem was actually saving these extra field forms. This is where it really required a hack to the main Joomla source. After making a backup copy, open components/com_content/models/article.php in your favorite editor. Around line 400 (in Joomla 1.5.14) find the line : $article->version++;Below this line add the following code snippet (from the admin area) : // pull in the parameters from the form $txt[] = "$k=$v"; |


