سعید حمزه زاده 104 ارسال شده در مرداد 91 نیاز هر کاربری هست که بتونه به بخش مطالب سایت یک فیلد جدید اضافه کنه مخصوصا در سایت های خبری که نیاز شدید به یک فیلد تیتر و یک فیلد سرتیتر است! کلی جستجو کردم در این مورد تنها یک آموزش انگلیسی پیدا کردم! تا مراحل پایانی تونستم پیش برم اما آخرای کار رو متوجه نشدم آموزش رو اینجا قرار میدم دوستان هرکس تونست بدون مترجم گوگل کامل و صحیح این رو توضیح بده تا بقیه دوستان هم استفاده کنند To add custom article submission field: Files needed to edit: i. jos_content table in joomla database ii. root/components/com_content/views/article/tmpl/default.php iii. root/components/com_content/views/article/tmpl/form.php iv. root/administrator/components/com_content/models/article.xml v. root/administrator/components/admin.content.html.php vi. root/administrator/components/config.xml vii. root/libraries/joomla/database/table/content.php 1. jos_content table update 1.1. Open up phpMyAdmin or your respective mysql database editor 1.1.i. If you’re working on your local server 1.1.i.a. Copy this link in you’re browser window http://localhost/phpmyadmin/index.php 1.1.i.b. If you have a lamp set up with xampp open the control panel a click on admin on the apache row and click on phpMyAdmin 1.2. Choose the respective database for the needed Joomla installation 1.3. Open the jos_content table 1.4. Click on structure 1.5. Scroll add form and add rows with the name of the custom fields you will be adding 2. default.php 2.1. Open “root/components/com_content/views/article/tmpl/default.php” 2.2. Scroll to line 25 and insert the following code replace “custom_field” with the name of its corresponding row in the jos_content table: <?php echo $this->escape($this->article-> custom_field); ?> 2.3. If you will be adding parameters to the field (i.e.: show custom_field, link custom_field, etc..) use the following code: <?php if ($this->params->get(‘show_ custom_field ‘)) : ?> <?php if ($this->params->get(‘link_ custom_field ‘) && $this- >article->readmore_link != ”) : ?> article->readmore_link; ?>” > <?php echo $this->escape($this->article-> custom_field); ?> <?php else : ?> <?php echo $this->escape($this->article-> custom_field); ?> <?php endif; ?> <?php endif; ?> 3. form.php 3.1. Let’s add our field to the front end submission form! 3.2. Open root/components/com_content/views/article/tmpl/form.php 3.3. Scroll to line 79 3.4. Insert and fields 3.4.i. Label Code: <?php echo JText::_( ‘custom_field ‘ ); ?>: 3.4.i.a. Replace “custom_field” with the text you would like to appear on the submission form screen. 3.4.i.b. This code renders the label text next to the field box 3.4.ii. Input Code custom_field ” size=”50″ maxlength=”100″ value=”<?php echo $this- >escape($this->article-> custom_field); ?>” /> 3.4.ii.a. Replace “custom_field” with the name of its corresponding row in the “jos_content” table 3.4.ii.b. This code will render the text field for user entry 4. article.xml 4.1. Follow these intructions if you’d like to add parameters to control the visibility and/or linkability of your field. And you can disseminate these instructions to add more parameters. 4.2. Open root/administrator/components/com_content/models/article.xml 4.3. Scroll to line 27 4.4. To add a parameter to choose whether or not your field will be visible on the front page add this code: custom_field ” description=”Show/Hide the articles subtitle”> Use Global No Yes 4.4.i. Replace “custom_field” with the name its corresponding row in the jos_content table 4.4.ii. The “name” field must match the variable used in the default.php to evaluate whether or not this parameter is set. To add a parameter to make the field linkable to the current article insert the following code: custom_field ” description=”TIPIFYESTITLECONTENTITEMS”> Use Global No Yes 4.4.iii. Replace “custom_field” with the name its corresponding row in the jos_content table 4.4.iv. The “name” field must match the variable used in the default.php to evaluate whether or not this parameter is set. 4.5. Both above codes render in the article editing view in the administrator Backend 5. admin.content.html.php 5.1. Open root/administrator/components/admin.content.html.php 5.2. Scroll to line 797 (Just after the that contains <?php echo $lists[‘state’]; ?> 5.3. Insert the following code: <?php echo JText::_( ‘ custom_field ‘ ); ?> custom_field ” size=”40″ maxlength=”255″ value=”<?php echo $row-> custom_field; ?>” /> 5.3.i. Replace “custom_field” with the label used for its corresponding row in the jos_content table. 5.3.ii. This code will create a new row just below the “title” field on the article submission form in the administrator backend. 6. config.xml 6.1. The following will add parameters to the article manager page parameter list 6.2. Open “root/administrator/components/config.xml” 6.3. Scroll to line 16 and insert: Article SubTitle” description=”Show/Hide the articles subtitle”> No Yes SubTitles” description=”TIPIFYESTITLECONTENTITEMS”> No Yes 6.3.i. The top is the parameter defining whether the field will be visible on the front end 6.3.ii. The bottom defines whether the field is a link 6.3.iii. Compare with previous xml edit. 7. Content.php 7.1. Open “root/libraries/joomla/database/table/content.php” 7.2. Scroll to line 33 7.3. Insert: var $subtitle = null; /** @var string */ 8. Extra notes 8.1. Steps 1,2,3, and 5 must be completed for a field to appear in the submission forms(both front and back), and render on the front end. 8.2. Steps 4 and 6 are parameter creations that add extra control over the fields. 8.3. To add the custom fields to the Section and Category view add: <?php echo $this->escape($this->this-> custom_field); ?> to the proper location and follow the page convention. 8.3.i. Insert in section/tmpl/blog_item.php line 25 8.3.ii. Add to section query compnents/com_content/models/section.php line 414 8.3.iii. “a.subtitle” 8.3.iv. Add module query models/category/php line 361 8.3.v. “a.subtitle” 8.4. The parameters for section and category blog and list view can be inserted in the same manner as the article parameters above. Find the proper xml file and add parameters for the custom field! نقل قول به اشتراک گذاری این ارسال لینک به ارسال به اشتراک گذاری در سایت های دیگر
سعید حمزه زاده 104 ارسال شده در مرداد 91 آدرس این آموزش: http://www.kavdesign.net/blog/coding/how-to-add-additional-field-in-the-joomla-article-administrator-page/ نقل قول به اشتراک گذاری این ارسال لینک به ارسال به اشتراک گذاری در سایت های دیگر