Pero no logro mostrar el contenido de un directorio a la hora de crear un nuevo contenido, pero cuando lo voy a editar sí me lista el directorio...
Y los métodos son similares entre sí: uno es para crear un contenido, y otro para editar el contenido...
Este es el que no me imprime los @dirs en la línea 39:
Using perl Syntax Highlighting
- sub content_add_form {
- my $self = shift;
- my $dbh = $self->dbh;
- my $language = $self->current_language();
- my $contenido = MyApp::Db::Content->new($dbh);
- my $fck = CGI::FCKeditor->new();
- $fck->set_name('content'); #HTML <input name>(default 'fck')
- $fck->set_base('../js/fckeditor/'); #FCKeditor Directory
- $fck->set_set('Default'); #FCKeditor Style(Basic 'Default')
- $fck->set_height('350');
- $fck->set_value('Cree su contenido');
- my $fk = $fck->fck; #output html source
- my $form = CGI::FormBuilder->new(
- name => 'form_contenido',
- fields => $contenido->{fields},
- method => 'post',
- fieldset => 'Info',
- action => 'content.pl?mode=save',
- stylesheet => "http://localhost/css/jquery-ui-1.8.4.custom.css",
- template => "templates/".$language.'/contenido_form.html',
- required => [qw(title content)]
- );
- #======================================================================
- #======================================================================
- # LEEMOS LA CARPETA DE TEMPLATES
- #======================================================================
- my $some_dir = $self->cfg('templates_dir')."/$language/".$self->cfg('template_name');
- find( \&w , $some_dir);
- sub w{
- if( -f "$some_dir/$_" ){push (@dirs,$_);}
- }
- die Dumper @dirs;
- #======================================================================
- #die $some_dir;
- #Poner el fck editor
- $form->tmpl_param(fck => $fk);
- $form->field(name => 'mode', type => 'hidden', value=>'save');
- $form->field(name => 'title', label => 'Titulo', size=>"50");
- $form->field(name => 'text_menu', label => 'Texto Menu');
- #$form->field(name => 'content', label => 'Contenido', type=> 'textarea' );
- $form->field(name => 'tags', label => 'Last Name', size => 50);
- $form->field(name => 'decription', label => 'Descripcion', size => 50);
- #$form->field(name => 'image', type => 'file', disabled => 1);
- $form->field(name => 'template', options => \@dirs, value => "template.html" );
- $form->field(name => 'status', options => [ qw(Publicado Inactivo)]);
- $form->field(name => 'show_in_menu', options => [ qw(SI NO)]);
- $form->field(name => 'target', options => [ qw(_self _blank)]);
- if ($form->submitted && $form->validate) {
- return $self->content_add_process($form);
- }
- #return $form->render;
- return $self->display($form->render(),'','text');
- }
Coloreado en 0.005 segundos, usando GeSHi 1.0.8.4
Y este otro sí me imprime los directorios:
Using perl Syntax Highlighting
- sub content_edit_form {
- my $self = shift;
- my $dbh = $self->dbh;
- my $q = $self->query();
- my $language = $self->current_language();
- my $contenido = MyApp::Db::Content->new($dbh);
- $contenido->retrieve($q->param('id'));
- my $fck = CGI::FCKeditor->new();
- $fck->set_name('content'); #HTML <input name>(default 'fck')
- $fck->set_base('../js/fckeditor/'); #FCKeditor Directory
- $fck->set_set('Default'); #FCKeditor Style(default 'Default')
- $fck->set_height('350');
- $fck->set_value($contenido->{data}->{content});
- my $fk = $fck->fck; #output html source
- my $form = CGI::FormBuilder->new(
- name => 'form_contenido',
- fields => $contenido->{fields},
- method => 'post',
- fieldset => 'Info',
- action => 'content.pl?mode=update',
- stylesheet => $self->cfg('site_url')."/css/jquery-ui-1.8.4.custom.css",
- template => "templates/".$language.'/contenido_form.html',
- required => [qw(title content)]
- );
- #======================================================================
- #======================================================================
- # LEEMOS LA CARPETA DE TEMPLATES
- #======================================================================
- my $some_dir = $self->cfg('templates_dir')."/$language/".$self->cfg('template_name');
- find( \&w , $some_dir);
- sub w{
- if( -f "$some_dir/$_" ){push (@dirs,$_);}
- }
- die Dumper @dirs;
- #======================================================================
- #Poner el fck editor
- $form->tmpl_param(fck => $fk);
- $form->field(name => 'mode', type => 'hidden', value=>'update');
- $form->field(name => 'id', type => 'hidden', value=>$q->param('id'));
- $form->field(name => 'title', label => 'Titulo', size => '60', value => $contenido->{data}->{title});
- $form->field(name => 'text_menu', label => 'Texto Menu', value => $contenido->{data}->{text_menu});
- #$form->field(name => 'content', label => 'Contenido', type=> 'textarea' );
- $form->field(name => 'tags', label => 'Last Name', size => 50, value => $contenido->{data}->{tags});
- $form->field(name => 'decription', label => 'Descripcion', size => 50, value => $contenido->{data}->{decription});
- $form->field(name => 'image', type => 'file', disabled => 1, value => $contenido->{data}->{image});
- $form->field(name => 'template', options => \@dirs, value => $contenido->{data}->{template} );
- #$form->field(name => 'template', options => \@dirs, value => "template.html" );
- $form->field(name => 'status', options => [ qw(Publicado Inactivo)], value => $contenido->{data}->{status});
- $form->field(name => 'show_in_menu', options => [ qw(SI NO)], value => $contenido->{data}->{show_in_menu});
- $form->field(name => 'target', options => [ qw(_self _blank)], value => $contenido->{data}->{target});
- if ($form->submitted && $form->validate) {
- return $self->content_edit_process($form);
- }
- #return $form->render;
- return $self->display($form->render(),'','text');
- }
Coloreado en 0.003 segundos, usando GeSHi 1.0.8.4
Los data dumpers para el segundo me arroja:
- $VAR1 = 'news.html'; $VAR2 = 'cart_widget_display.html'; $VAR3 = 'template_2.html'; $VAR4 = 'store_display.html'; $VAR5 = 'content.html'; $VAR6 = 'cart_display.html'; $VAR7 = 'store.html'; $VAR8 = 'template_1.html'; $VAR9 = 'item_display.html'; $VAR10 = 'gallery.html'; $VAR11 = 'news_display.html'; $VAR12 = 'gallery_display.html'; $VAR13 = 'home.html'; $VAR14 = 'template.html';
Y para el primero no me arroja nada :S Estoy confundido. No sé qué haya hecho mal.