HTML Logo by World Wide Web Consortium (www.w3.org). Click to learn more about our commitment to accessibility and standards.

Moving forward with Composr

ocPortal has been relaunched as Composr CMS, which is now in beta. ocPortal 9 will be superseded by Composr 10.

Head over to compo.sr for our new site, and to our migration roadmap. Existing ocPortal member accounts have been mirrored.


Is it possible to customize the "ADD a video" page/template?

Login / Search

 [ Join | More ]
 Add topic 
Posted
Rating:
#103386 (In Topic #20237)
Avatar

Well-settled

What I want to do is customize the layout of the "Add a video" page. The attachment is basically what i want to do (changes highlighted  in green).



The idea is to basically only offer the option to share a Youtube video via a URL and not allow users to upload videos form a local source. Also, because users will only be allowed to use Youtube videos there is no reason to leave the "Thumbnail," the "Video length," the "Width" and the "Height" options because it will automatically grab that information from Youtube.

Is there a way for me to do this and if so can someone point me the the right direction?

As always, thats in advance,
LocalMC
Back to the top
 
Posted
Rating:
#103398
Avatar

Community saint

A note to Chris or anybody with override experience: Could you check the override code below when you have time? I'm trying to define an override for a function of the Module_cms_galleries_alt class in cms/pages/modules/cms_galleries.php, but it isn't working as-is. It doesn't throw any errors, it just seems the original function is still being used and not the function from the override in modules_custom. If I replace the function in the original cms_galleries.php file and place the whole file as an override in the modules_custom directory, it works as intended.

And for LocalMC: The form in the 'Add video' gallery page is built in the cms/pages/modules/cms_galleries.php script and not directly editable via a template. But I found it wasn't too difficult to make the necessary edits to cms_galleries.php. I'm trying to do a proper override for it, but I've hit a bit of a road block.

First, the easy part… To change the 'Add video' text, go to Admin Zone->Style->Translate/re-phrase the Software. Select the galleries language file and click the Choose button. Scroll down a bit more than half way to find the ADD_VIDEO name in the left column, and in the right column change the text to Add YouTube video, and then scroll to the bottom and click Save. This will also change the 'Add video' links that appear in Gallery pages that members can click to get to the 'Add video' gallery page.

To remove the form fields you specified, we will have to override the get_form_fields function of the Module_cms_gelleries_alt class in cms/pages/modules/cms_galleries.php. Below is what I was hoping would be a fairly straight-forward override, but it doesn't work as-is. What you can do while waiting for a proper override is copy just the function from the code box below and paste it into cms_galleries.php, overwriting the existing get_form_fields function that should start at line 1338, and save it to the cms/pages/modules_custom directory. There are three classes defined in cms_galleries.php and each one has a get_form_fields function. Be sure to replace the correct one and not all of them, just the get_form_fields function in the Module_cms_galleries_alt class. If copying just the function from the code box below, be sure not to copy the very last curly brace that closes the Mx_cms_galleries_alt class.

Here is the override code I placed in cms/pages/modules_custom/cms_galleries.php, but the original get_forms_function is still being called instead of this one:

Code (php)

<?php

class Mx_cms_galleries_alt extends Module_cms_galleries_alt
{

        //Override function to remove some of the fields from the Add Video page.
        /**
         * Get tempcode for a video adding/editing form.
         *
         * @param  SHORT_TEXT           The title
         * @param  ID_TEXT                      The gallery
         * @param  LONG_TEXT                    The video description
         * @param  URLPATH                      The URL to the video file (blank: not yet added)
         * @param  URLPATH                      The URL to the thumbnail
         * @param  BINARY                               Video validation status
         * @param  ?BINARY                      Whether rating is allowed (NULL: decide statistically, based on existing choices)
         * @param  ?SHORT_INTEGER       Whether comments are allowed (0=no, 1=yes, 2=review style) (NULL: decide statistically, based on existing choices)
         * @param  ?BINARY                      Whether trackbacks are allowed (NULL: decide statistically, based on existing choices)
         * @param  LONG_TEXT                    Notes for the video
         * @param  ?integer                     The length of the video (NULL: not yet added, so not yet known)
         * @param  ?integer                     The width of the video (NULL: not yet added, so not yet known)
         * @param  ?integer                     The height of the video (NULL: not yet added, so not yet known)
         * @return array                                A pair: the tempcode for the visible fields, and the tempcode for the hidden fields
         */

        function get_form_fields($title='',$cat='',$comments='',$url='',$thumb_url='',$validated=1,$allow_rating=NULL,$allow_comments=NULL,$allow_trackbacks=NULL,$notes='',$video_length=NULL,$video_width=NULL,$video_height=NULL)
        {
                list($allow_rating,$allow_comments,$allow_trackbacks)=$this->choose_feedback_fields_statistically($allow_rating,$allow_comments,$allow_trackbacks);

                global $NON_CANONICAL_PARAMS;
                $NON_CANONICAL_PARAMS[]='cat';
                $NON_CANONICAL_PARAMS[]='validated';

                //$no_thumb_needed=(get_option('ffmpeg_path')!='') || (class_exists('ffmpeg_movie'));

                if ($cat=='')
                {
                        $cat=get_param('cat','');
                }

                $fields=new ocp_tempcode();
                $hidden=new ocp_tempcode();
                require_code('form_templates');
                handle_max_file_size($hidden);
                if (strpos($cat,'?')!==false) $cat=str_replace('?',strval(get_member()),$cat);
                $fields->attach(form_input_line(do_lang_tempcode('TITLE'),do_lang_tempcode('DESCRIPTION_TITLE'),'title',$title,false));

                $fields->attach(form_input_tree_list(do_lang_tempcode('GALLERY'),do_lang_tempcode('DESCRIPTION_GALLERY'),'cat',NULL,'choose_gallery',array('filter'=>'only_conventional_galleries','must_accept_videos'=>true,'addable_filter'=>true),true,$cat));
                $supported=get_allowed_video_file_types();

                $set_name='video';
                $required=true;
                $set_title=do_lang_tempcode('VIDEO');
                // $field_set=alternate_fields_set__start($set_name);

                // $field_set->attach(form_input_upload(do_lang_tempcode('UPLOAD'),'','file',false,NULL,NULL,true,$supported));
               
                // $field_set->attach(form_input_line(do_lang_tempcode('URL'),'','url',$url,false));
                $fields->attach(form_input_line(do_lang_tempcode('URL'),'The full URL to your video watch page on YouTube.','url',$url,true)); //Hard coded a description for what the URL field should be

                // $fields->attach(alternate_fields_set__end($set_name,$set_title,'',$field_set,$required));

/*              if ($validated==0)
                {
                        $validated=get_param_integer('validated',0);
                        if ($validated==1) attach_message(do_lang_tempcode('WILL_BE_VALIDATED_WHEN_SAVING'));
                }
                $thumb_width=intval(get_option('thumb_width'));
                $validated_field=new ocp_tempcode();
                if (has_some_cat_specific_permission(get_member(),'bypass_validation_'.$this->permissions_require.'range_content',NULL,$this->permissions_cat_require))
                        if (addon_installed('unvalidated'))
                                $validated_field=form_input_tick(do_lang_tempcode('VALIDATED'),do_lang_tempcode('DESCRIPTION_VALIDATED'),'validated',$validated==1); */

                $description_field=form_input_text_comcode(do_lang_tempcode('DESCRIPTION'),do_lang_tempcode('DESCRIPTION_DESCRIPTION_ACCESSIBILITY'),'comments',$comments,false);
/*              if ($no_thumb_needed)
                { */

                        $fields->attach($description_field);
/*                      $fields->attach($validated_field);
                        $temp=do_template('FORM_SCREEN_FIELD_SPACER',array('TITLE'=>do_lang_tempcode('ADVANCED'),'SECTION_HIDDEN'=>true));
                        $fields->attach($temp);
                }

                $set_name='thumbnail';
                $required=false;//(!$no_thumb_needed) && (get_option('allow_audio_videos')=='0');       Youtube won't require one for example
                $set_title=do_lang_tempcode('THUMBNAIL');
                $field_set=alternate_fields_set__start($set_name);

                $field_set->attach(form_input_upload(do_lang_tempcode('UPLOAD'),'','file2',false,NULL,NULL,true,str_replace(' ','',get_option('valid_images'))));

                $field_set->attach(form_input_line(do_lang_tempcode('URL'),'','thumb_url',$thumb_url,false));

                $fields->attach(alternate_fields_set__end($set_name,$set_title,do_lang_tempcode('_DESCRIPTION_THUMBNAIL',integer_format($thumb_width)),$field_set,$required));

                if (!$no_thumb_needed)
                {
                        $fields->attach($description_field);
                }
                $fields->attach(form_input_integer(do_lang_tempcode('VIDEO_LENGTH'),do_lang_tempcode('DESCRIPTION_VIDEO_LENGTH'),'video_length',$video_length,false));
                $fields->attach(form_input_integer(do_lang_tempcode('WIDTH'),do_lang_tempcode('DESCRIPTION_VIDEO_WIDTH'),'video_width',$video_width,false));
                $fields->attach(form_input_integer(do_lang_tempcode('HEIGHT'),do_lang_tempcode('DESCRIPTION_VIDEO_HEIGHT'),'video_height',$video_height,false));
                if (!$no_thumb_needed)
                {
                        $fields->attach($validated_field);
                } */


                require_code('feedback2');
                $fields->attach(feedback_fields($allow_rating==1,$allow_comments==1,$allow_trackbacks==1,false,$notes,$allow_comments==2));

                return array($fields,$hidden);
        }
}
 
Back to the top
 
Posted
Item has a rating of 5 (Liked by Jason Verhagen)  
Rating:
#103423
Avatar

@Jason…

It's because in this case, the object is not being instantiated via a direct module call, but rather chained through from the main module object. I did a test on cms_downloads, got it to work…

PHP code

<?php

/**
 * Module page class.
 */
class Mx_cms_downloads extends Module_cms_downloads
{
    
/**
     * Standard aed_module run_start.
     *
     * @param  ID_TEXT        The type of module execution
     * @return tempcode        The output of the run
     */
    
function run_start($type)
    {
        
$this->cat_aed_module=new Module_cms_downloads_cat();
        
$this->alt_aed_module=new Mx_cms_downloads_alt();

        
$GLOBALS['MODULE_CMS_DOWNLOADS']=$this;

        
$GLOBALS['HELPER_PANEL_PIC']='pagepics/downloads';
        
$GLOBALS['HELPER_PANEL_TUTORIAL']='tut_downloads';

        
require_lang('downloads');
        
require_code('downloads');
        
require_code('downloads2');
        
require_css('downloads');

        
// Decide what to do
        
if ($type=='misc') return $this->misc();
        if (
$type=='import') return $this->import_interface();
        if (
$type=='_import') return $this->_import();
        if (
$type=='import2') return $this->import_interface2();
        if (
$type=='_import2') return $this->_import2();

        return new 
ocp_tempcode();
    }
}

class 
Mx_cms_downloads_alt extends Module_cms_downloads_alt
{
    function 
get_form_fields($category='',$parent_id=NULL,$description='',$notes='',$category_id=-1,$rep_image='')
    {
        @exit(
'hello');
    }
}


Become a fan of ocPortal on Facebook or add me as a friend. Add me on on Twitter.
Was I helpful?
  • If not, please let us know how we can do better (please try and propose any bigger ideas in such a way that they are fundable and scalable).
  • If so, please let others know about ocPortal whenever you see the opportunity.
  • If my reply is too Vulcan or expressed too much in business-strategy terms, and not particularly personal, I apologise. As a company & project maintainer, time is very limited to me, so usually when I write a reply I try and make it generic advice to all readers. I'm also naturally a joined-up thinker, so I always express my thoughts in combined business and technical terms. I recognise not everyone likes that, don't let my Vulcan-thinking stop you enjoying ocPortal on fun personal projects.
  • If my response can inspire a community tutorial, that's a great way of giving back to the project as a user.
Back to the top
 
Posted
Rating:
#103425
Avatar

Community saint

Thanks Chris!

I'll get a proper override done and hopefully get it posted in an hour or two.
Back to the top
 
Posted
Rating:
#103426
Avatar

Fan in action

I have basically the same question so i felt like i did not need to make a new thread, How would i go about changing some text on the join page step 2 after the rules agreement? I wanted to change the text under some text boxes. I was looking at the file join.php in pages/modules but i dont see how it brings in the text boxes and text since i dont know php at all or im looking at wrong file.
Back to the top
 
Posted
Rating:
#103428
Avatar

Community saint

Here it is LocalMC. Attached to his post is a cms_galleries.php file that can be placed in the cms/pages/modules_custom directory. The code posted in my first message above contains a bug that prevents video submissions from being validated through that code. This new code adds the Validation form field back in, but it is only visible to site admin and staff members to allow them to validate the submissions. This isn't 100% tested, but I did throw some common scenarios at it. I tested uploads with regular member without the bypass validation permission. I tested admin uploads. I tested admin validation of regular member submissions. I think the only likely scenario I didn't test was a regular member upload where the member has the permission to bypass validation. If you see anything that doesn't seem to be functioning correctly, post it here with the details and I'll take another look at it.

And now for the warning... Although I'd say the probability is fairly low, significant changes made to ocPortal through bug fixes or upgrades could change the original cms_galleries.php enough for this override to break things. You should always double check bug fixes and upgrades to see if the cms_galleries.php has significant changes, or at least go to the Add Video page and do a test to ensure it still works after applying bug fixes and upgrades. If things do become broken, the quick and simple fix is to remove the cms/pages/modules_custom/cms_galleries.php override file until you can figure out what needs to be fixed there.

One last note. You will want to make sure the 'Allow audio as video' option in Admin Zone->Setup->Configuration->Site options in the Advanced section is unchecked. If that option checkbox is checked, the Add Video page will have a note on it that states audio uploads are allowed even though they aren't.

For any others interested in this, this override removes the ability to upload video and/or audio files to the gallery and only allows for video URL submission (ie. YouTube videos).

I'll repeat the install instructions again...install this override in the cms/pages/modules_custom directory and not in the cms/pages/modules directory! If you already have a cms_galleries.php file in the modules_custom directory that doesn't pertain to this particular override, post a message here before overwriting it.

Attachment
An override to only allow URL (YouTube) video uploads in the gallery.
» Download: cms_galleries.php (7 Kb, 91 downloads so far)
Back to the top
 
Posted
Rating:
#103429
Avatar

Community saint

Oster said

I have basically the same question so i felt like i did not need to make a new thread, How would i go about changing some text on the join page step 2 after the rules agreement? I wanted to change the text under some text boxes. I was looking at the file join.php in pages/modules but i dont see how it brings in the text boxes and text since i dont know php at all or im looking at wrong file.


Most of those types of text strings will be in one of the language .ini files. In this case, I believe all of those text strings are in the lang/EN/ocf.ini file. So you would go to Admin Zone->Style->Translate/re-phrase the software, select ocf for the Language File Codename, and click the Choose button. From there you will probably need to do some searching to find the text, like CTRL-F in the browser and type in a snippet of the text you are looking for and you should be able to find the right language string to change. Don't forget to scroll all the way to the bottom of the page to click the Save button when you are done editing. 

Any Join form fields that don't have descriptions may require some php programming to add them.
Back to the top
 
Posted
Rating:
#103430
Avatar

Fan in action

Well I could not find the text but maybe you can? This was the text i was trying to change
Back to the top
 
Posted
Rating:
#103431
Avatar

Community saint

That one is in the ocf.ini. Actually, a quicker way to find these language strings is to use the search box at the top of the Admin Zone (I keep forgetting how powerful and versatile it is!). Just type in the first few words of the string:

This must be a working e-mail

And it should give you a link like this:

http://[ your web site ]/adminzone/index.php?page=admin_lang&type=misc&lang=EN&lang_file=ocf#jmp_MUST_BE_REAL_ADDRESS
Back to the top
 
Posted
Rating:
#103432
Avatar

Well-settled

Jason,

I've installed the cms_galleries.php file as you instructed and so far everything looks great! I'm going to do some tests of my own and will let you know the outcome but as for now thank you. This is exactly what I had in mind.

Much appreciated,
LocalMC
Back to the top
 
Posted
Rating:
#103434
Avatar

Fan in action

Jason Verhagen said

That one is in the ocf.ini. Actually, a quicker way to find these language strings is to use the search box at the top of the Admin Zone (I keep forgetting how powerful and versatile it is!). Just type in the first few words of the string:

This must be a working e-mail

And it should give you a link like this:

http://[ your web site ]/adminzone/index.php?page=admin_lang&type=misc&lang=EN&lang_file=ocf#jmp_MUST_BE_REAL_ADDRESS

Okay thank you and wow that search engine is great! Now what if i wanted to add or remove a field like the "Recive emails from other users"?
Back to the top
 
Posted
Rating:
#103435
Avatar

Community saint

The 'Receive emails from other users' option can be turned on and off by going to Admin Zone->Setup->Configuration->Member and forum options. Once there, look in the General section for the 'Allow members to opt-out of e-mails' checkbox and uncheck it to remove it from the Join form. Some other options there also affect the sign up process and the Join form. New fields can be added to the Join form by going to Admin Zone->Tools->Members and selecting the Custom Profile Fields option. From there, you can select the Edit option and check to see if there is already a custom profile field that fits your needs and you can edit the field to change it to display on the Join form and set it to be a required field if that's what you want. If none of the existing custom profile fields fit your needs, you can go back and use the Add option to add your own.
Back to the top
 
There are too many online users to list.
Control functions:

Quick reply   Contract

Your name:
Your message: