Foros del Web » Programando para Internet » PHP »

Aclaracion php en joomla

Estas en el tema de Aclaracion php en joomla en el foro de PHP en Foros del Web. Quiero saver si me puden explicar como hacer esto. So the general use of mosCountModules would be: Código: <?php if($this->countModules('condition')) : ?> do something <?php ...
  #1 (permalink)  
Antiguo 04/04/2009, 21:51
 
Fecha de Ingreso: septiembre-2008
Mensajes: 101
Antigüedad: 15 años, 5 meses
Puntos: 4
Aclaracion php en joomla

Quiero saver si me puden explicar como hacer esto.

So the general use of mosCountModules would be:
Código:
<?php if($this->countModules('condition')) : ?>
   do something
<?php else : ?>
   do something else
<?php endif; ?>
There are four possible conditions. As an example let's count the number of modules in Figure 9.7. We could insert this code somewhere in the index.php:
Código:
left=<?php echo $this->countModules('left');?><br />
left and right=<?php echo $this->countModules('left and right');?><br />
left or right=<?php echo $this->countModules('left or right');?><br />
left + right=<?php echo $this->countModules('left + right');?>
* countModules('left'). Will return 4; there are 4 modules on the left.
* countModules('left and right'). Will return 1; there is a module in left and right position.
* countModules('left or right'). Will return 1; there is a module in left or right position.
* countModules('left + right'). Will return 7; counting the modules in left and right. position

In this situation, we need to use the function that allows us to count the modules present in a specific location. So for example, if there is no content published in the right column, we can adjust the column sizes to fill that space.

There are several ways to do this. We could put the conditional statement in the body to not show the content and then have a different style for the content based on what columns were there. To make it as easy as possible, I have a series of conditional statements in the head tag that (re)define some CSS styles:
Código:
<?php
if($this->countModules('left and right') == 0) $contentwidth = "100";
if($this->countModules('left or right') == 1) $contentwidth = "80";
if($this->countModules('left and right') == 1) $contentwidth = "60";
?>
So we count:

* If there is nothing in left OR right, we are 100%.
* If there is something in left OR right, we are 80%.
* If there is something in left AND something in right, we are 60%.

We then need to change the index.php file in the content div to:
<div id="content<?php echo $contentwidth; ?>">

Change the layout css to:
Código:
#content60 {float:left;width:60%;overflow:hidden;}
#content80 {float:left;width:80%;overflow:hidden;}
#content100 {float:left;width:100%;overflow:hidden;}
The PHP conditional statements in the head must appear after the line that links to the template.css file. This is because if there are two identical CSS style rules; the one that is last will overwrite all the others.
This can also be done in a similar fashion by having the if statement import a sub CSS file.

TIP
While you try to troubleshoot your conditional statements, you can add a line of code into your index.php, like this, to show what the value is:
This content column is <?php echo $contentwidth; ?>% wide

So we are half-way there, but now we have empty div containers where the columns are.
Hiding Module Code

When creating collapsible columns, it is good practice to set up the modules not to be generated if there is no content there. If this is not done, the pages will have empty <div>s in them, which can lead to cross browser issues.

To hide the empty <div>, the following if statement is used:
Código:
  <?php if($this->countModules('left')) : ?>
  <div id="sidebar">
    <div class="inside">
      <jdoc:include type="modules" name="left" style="xhtml" />
    </div>
  </div>
  <?php endif; ?>
Using this code, if there is nothing published in left, then <div id="sidebar"> will not be outputted.

Using these techniques for our left and right columns, our index.php file now looks like the following code. We will also add an include for the breadcrumbs module, the module that shows the current page and pathway. Note that this now needs to be included in the index.php file and also published as a module.
Código:
<?php // no direct access defined( '_JEXEC' ) or die( 'Restricted access' ); ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0
Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
xml:lang="<?php echo $this->language; ?>"
lang="<?php echo $this->language; ?>" >
<head>
<jdoc:include type="head" />
<link rel="stylesheet" href="templates/system/css/system.css" type="text/css" />
<link rel="stylesheet" href="templates/system/css/general.css" type="text/css" />
<link rel="stylesheet" href="templates/<?php echo $this->template ?>/css/template.css" type="text/css" />
<?php if($this->countModules('left and right') == 0) $contentwidth = "100"; if($this->countModules('left or right') == 1) $contentwidth = "80"; if($this->countModules('left and right') == 1) $contentwidth = "60"; ?>
</head>
<body>
<div id="wrap">
  <div id="header">     <div class="inside">         <h1><?php echo $mainframe->getCfg('sitename');?></h1>
      <jdoc:include type="modules" name="top" style="xhtml" />     </div>
  </div>
  <?php if($this->countModules('left')) : ?>
  <div id="sidebar">     <div class="inside">
      <jdoc:include type="modules" name="left" style="xhtml" />     </div>
  </div>
  <?php endif; ?>
<div id="content<?php echo $contentwidth; ?>">     <div class="inside">
      <jdoc:include type="module" name="breadcrumbs" style="none" />
      <jdoc:include type="component" />     </div>
  </div>
<?php if($this->countModules('right')) : ?>
  <div id="sidebar-2">     <div class="inside">
      <jdoc:include type="modules" name="right" style="xhtml" />     </div>
  </div>
  <?php endif; ?>
  <?php if($this->countModules('footer')) : ?>
  <div id="footer">     <div class="inside">
      <jdoc:include type="modules" name="footer" style="xhtml" />     </div>
  </div>
  <?php endif; ?>
<!--end of wrap-->
</body>
</html>
como ven esta en ingles eso me dificulta un poco mas la cosa si algien me pudiese horientar se lo agradeseria
  #2 (permalink)  
Antiguo 04/04/2009, 22:02
Avatar de Ronruby  
Fecha de Ingreso: julio-2008
Ubicación: 18°30'N, 69°59'W
Mensajes: 4.879
Antigüedad: 15 años, 8 meses
Puntos: 416
Respuesta: Aclaracion php en joomla

Hay un foro dedicado a Joomla:
http://www.forosdelweb.com/f119/
  #3 (permalink)  
Antiguo 04/04/2009, 22:04
 
Fecha de Ingreso: septiembre-2008
Mensajes: 101
Antigüedad: 15 años, 5 meses
Puntos: 4
Respuesta: Aclaracion php en joomla

se pero esto no se refiere mas hacie el php ya que trabaja en el "if" en php pero no tengo idea de como usarlo muy bien :S pero poteare aya a ver si responde espero no romper alguna regla

Última edición por arkang31; 04/04/2009 a las 22:05 Razón: falto algo
  #4 (permalink)  
Antiguo 04/04/2009, 22:10
Avatar de Ronruby  
Fecha de Ingreso: julio-2008
Ubicación: 18°30'N, 69°59'W
Mensajes: 4.879
Antigüedad: 15 años, 8 meses
Puntos: 416
Respuesta: Aclaracion php en joomla

Por lo menos yo no conozco Joomla, y aunque esta hecho en PHP, no puedo orientarte sobre como trabajar con este porque nunca lo he usado, no se que devuelve $this->countModules('condition'). Un if es igual en todos los lenguajes de programacion:

if(condicion) { //si se cumple la condicion
//ejecuto lo que esta dentro de las llaves
}

Si la condicion dentro de los parentesis es TRUE, entonces se ejecuta el bloque que esta dentro de las llaves.
Lo unico diferente es que en tu caso, utilizan la sintaxis alterna de las estructuras de control:
http://www.php.net/manual/en/control...ive-syntax.php
  #5 (permalink)  
Antiguo 04/04/2009, 22:46
Avatar de jpinedo
Colaborador
 
Fecha de Ingreso: septiembre-2003
Ubicación: Lima, Perú
Mensajes: 3.120
Antigüedad: 20 años, 6 meses
Puntos: 41
Respuesta: Aclaracion php en joomla

Tema cerrado. Continúa en:
http://www.forosdelweb.com/f119/php-joomla-686566/

Saludos,
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Tema Cerrado




La zona horaria es GMT -6. Ahora son las 22:42.