1

as the title says. is it possible to add an extra field to the "New Item" in the administration panel? just below the "title" i want the same field called "title 2" and then display it in the frontend? is it possible somehow without downloading lots of extensions etc?

there is this tutorial, but this is only for the fields in the new article page. want the same but for new menu item.

http://andresgallo.com/2011/08/28/add-custom-content-fields-to-joomla-pt-2-on-the-front-end/

im using joomla 3.8 edit: So i have gotten a little bit further. i now added a to the: Administrator/Components/com_menus/model/form/menu.xml

<field
            name="title_danish"
            type="title_danish"
            label="COM_MENUS_ITEM_FIELD_TITLE_LABEL"
            description="COM_MENUS_ITEM_FIELD_TITLE_DESC"
            class="input-xxlarge input-large-text"
            size="40"/>

then i added this line to Administrator/Components/com_menus/views/item/tmpl/edit.php

  <?php echo $this->form->getInput('title_danish', null, $this->userID); ?>

and also i duplicated the title to title_danish in the database, so it saves it.

the only thing remaining is displaying the outcome of title_danish in my com_content in my fronted. i dont know how to do that. can anyone help here?

btw the above way i have done it. is it the right way or are their an easier way?

  • how do i bump my topic? – Peter Feb 8 '16 at 21:04
1

You have made some mistakes:

  1. You need to override the menu for the kind of content you want to display.

If you want the default front-page-menu; the featured menu item, then find /components/com_content/views/featured/tmpl/default.xml and ditto default.php and default_*.php, and copy these to /templates/yourtemplate/html/com_content/featured/. Now you are ready to make your changes. Change the xml-file like this:

Layout-section:

<layout title="Special view with danish and english title" 
option="COM_CONTENT_FEATURED_VIEW_DEFAULT_OPTION">

And in fieldset article, add

<field
  name="title_danish" type="text" label="Dansk tittel"
  description="Her er dansk tittel"
  class="input-xxlarge input-large-text"
  size="40"/>

Use type=text, not type=title_danish as you did in your question

  1. Make a menu item, and fill in the new title. You should find the new field under the Options - tab in the menu administration for menu type featured. If you want a different menu type, override this content type instead.

  2. Output your new field in the frontend.

The field is saved in the menu item parameters, so to get it, you'll need to use something like:

echo $this->params->get('title_danish');

You can add this wherever it suits you best, but I guess somewhere in your new file /templates/yourtemplate/html/com_content/featured/default.php is a good choice. Hope this clears up some things...

  • Thank you very much. it works fine, but is it possible to display it below the "Menu title" in the frontpage, or do i have to go to a submenu(featured/category) and add it there? i know its not much, but i have to write maybe 50-100 pieces of them. and thats so much. :) – Peter Feb 9 '16 at 0:28
  • one more thing, is it possible to show it in the Main menu? like when it displays the english title, then besides that, it displays the danish title to? :) – Peter Feb 9 '16 at 0:32
  • did you have a suggestion to Add it to the menus? – Peter Feb 9 '16 at 19:11
  • Adding an extra field to the menu itself is possible I guess, but I think it needs quite a lot of work. You can override mod_menu - output, but afaik this module is limited in the data it collects, so you probably have to write your own menu module. – jonasfh Feb 9 '16 at 20:21
  • Just a thought: It might be better to accomplish what you need by adding an extra field to articles instead of menus? Recipe for this is here: docs.joomla.org/… – jonasfh Feb 9 '16 at 20:24
0

please try to put that line under or top of the main title field

Look for that line at file: /home/web/public_html/joomla/components/com_content/views/form/tmpl/edit.php

<?php echo $this->form->renderField('title'); ?>

and place that line before or after it:

<?php echo $this->form->renderField('title_danish'); ?>

Hope it helps

  • Hello, it doesn't work. i think i have to write something in the components/com_content/views/category/tmpl/blog.php it shows this: <?php $active = JFactory::getApplication()->getMenu()->getActive(); echo $active->title; ?> if i change the title with title_danish nothing happens. so somehow i have to change that. @hasan – Peter Feb 7 '16 at 20:49
  • Oh i am sorry i thought you want to place title_danish field in com_content and display it in com_content only, not in com_menus and display it in com_content – TheNextStage Feb 8 '16 at 21:10
  • But can i ask you why you want that field maybe i can help by another way if i know why you want it – TheNextStage Feb 8 '16 at 21:11
  • Hi again. basically i want to call the same menu items for 2 different things. lets say in english its called "homepage" i want to call it in danish "forside". and i want to display both of them the same time. and i dont want to use the multi language joomla component. i just need a simple way to show same title 2 different languages. – Peter Feb 8 '16 at 21:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.