VirtueMart Forum

VirtueMart 2 + 3 + 4 => Templating & Layouts => Topic started by: SightVision on March 05, 2013, 20:32:29 PM

Title: Category description ONLY on first page
Post by: SightVision on March 05, 2013, 20:32:29 PM
Hello everyone,

does anyone knowhow I can show de category description ONLY on the first page of the categroy view?

Thanks!!
Title: Re: Category description ONLY on first page
Post by: socratesmakuyana on March 09, 2013, 10:02:55 AM
Here is how I solved the issue. Go to the the "com_virtuemart/views/categories/tmpl/default.php" file, or you can change whatever template file you are using for your categories view.

the original file before it was edited looked like this

          // Show Category ?>
          <div class="category floatleft<?php echo $category_cellwidth . $show_vertical_separator ?>">
             <div class="spacer">
                <h2>
                   <a href="<?php echo $caturl ?>" title="<?php echo $category->category_name ?>">
                   <?php echo $category->category_name ?>
                   <br />
                   <?php // if ($category->ids) {
                      echo $category->images[0]->displayMediaThumb("",false);
                   //} ?>
                   </a>
                </h2>
            </div>

          </div>
...


After editing the file to display the category description, the file looked like this

....
          // Show Category ?>
          <div class="category floatleft<?php echo $category_cellwidth . $show_vertical_separator ?>">
             <div class="spacer">
                <h2>
                   <a href="<?php echo $caturl ?>" title="<?php echo $category->category_name ?>">
                   <?php echo $category->category_name ?>
                   <br />
                   <?php // if ($category->ids) {
                      echo $category->images[0]->displayMediaThumb("",false);
                   //} ?>
                   </a>
                </h2>
            </div>

                                This is the added text.
            <!-- Show category description -->
            <div class="category-description">
               <?php echo $category->category_description ?>
            </div>

          </div>
....

Now after this has been done, the category description is displayed on the categories layout page.
Title: Re: Category description ONLY on first page
Post by: PromoNet on February 09, 2015, 13:38:30 PM
You have not answered the question that was asked. They asked how to display the description on ONLY the first page...   I.e. for SEO the category description should not display on page 2/3/4/5 etc of the category due to duplicate content.

I will look for a resolution and if I find one I will post it.
Title: Re: Category description ONLY on first page
Post by: GJC Web Design on February 09, 2015, 13:42:38 PM
just hide it by css when a snippet detects that the limitstart var is > 0

something like

$limitstart = JRequest::getVar('limitstart');
if($limitstart > 0) {
echo '<style type="text/css">
.category-description {
    display.none;
   }
  </style>';

}
Title: Re: Category description ONLY on first page
Post by: PromoNet on February 09, 2015, 13:53:09 PM
Lol you beat me to it!  I was just posting.

Find this in the default category view

$this->category->category_description;

and change it to this
<?php $url 'http://' $_SERVER['SERVER_NAME'] . $_SERVER['REQUEST_URI'];
if (
false !== strpos($url,'limitstart')) {
    echo 
'';
} else {
    echo 
$this->category->category_description;
?>


This checks for the limitstart text in the URL and if it exists shows nothing. If it doesent then it shows the category description.
   
Title: Re: Category description ONLY on first page
Post by: jenkinhill on February 09, 2015, 15:10:04 PM
Don't know if the OPs are really bothered about this now. The thread is from 2 years ago........    ;)
Title: Re: Category description ONLY on first page
Post by: GJC Web Design on February 09, 2015, 23:44:31 PM
Ah you never know - he may still be struggling with this...   :o