Foros del Web » Creando para Internet » Sistemas de gestión de contenidos » Joomla »

php en joomla

Estas en el tema de php en joomla en el foro de Joomla 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, 23:06
 
Fecha de Ingreso: septiembre-2008
Mensajes: 101
Antigüedad: 11 años, 4 meses
Puntos: 4
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 05/04/2009, 09:59
 
Fecha de Ingreso: septiembre-2008
Mensajes: 101
Antigüedad: 11 años, 4 meses
Puntos: 4
Respuesta: php en joomla

Código:
<?php if($this->countModules('top')) : ?>
<div id="top"><jdoc:include type="modules" name="top" style="xhtml" /></div>
<?php endif; ?>
<div id="header"></div>
<div id="container">
<?php if($this->countModules('left')) : ?>
<div id="left"><jdoc:include type="modules" name="left" style="xhtml" /></div>
<?php endif; ?>
<?php if($this->countModules('right')) : ?>
<div id="right"><jdoc:include type="modules" name="right" style="xhtml" /></div>
<?php endif; ?>
esta es la repuestas enserrar el div entre
<?php if($this->countModules('top')) : ?>
<?php endif; ?>
  #3 (permalink)  
Antiguo 08/04/2009, 19:52
 
Fecha de Ingreso: junio-2003
Ubicación: Distrito Federal
Mensajes: 238
Antigüedad: 16 años, 8 meses
Puntos: 4
Respuesta: php en joomla

Creo que explica como hacer variable tu diseño. Pero definitivamente necesitas saber algo de inglés.
__________________
Urano González
Experto Joomla!
www.Experto-Joomla.com
www.Experto-Hosting.com
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.
Respuesta




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