Adding Joomla Article Order number inside an article - joomla

I am trying to create a Joomla site that would be showing the article order numbers (not Article ID) inside each article. that way I can handle it like a book.
Each page will show the article order number at the corner - like a page.
That way I will be able to have the site modeled by categories and pages will show with their page number (Article Order number) at the corner.
I want to give the user the ability to watch the pages like they are reading books by categories.
I would be happy to know - how can I add the article order number (for each category) inside the article itself.
I am sure that there is a PHP code that can do that.
Thanks so much for your help and assist.
Arye

You'll need to override the default article layout in your template.
If your template doesn't already have an article layout, you can copy the default layout from components/com_content/views/article/tmpl/default.php inside your template override templates\[YOURTEMPLATE]\html\com_content\article\default.php (replacing [YOURTEMPLATE] by your actual template name.
You can then display ordering where you require it within your template by using
<?php echo $this->item->ordering; ?>
You'll most likely want to either check for a certain condition (the article's category, perhaps) to determine whether you want to display the ordering.
Another option is to create an alternative layout instead of overriding the default one. You can rename default.php in your template to, let's say bookpage.php. You will then be able to pick the new layout as an alternative layout in your articles' options.

you can get article id by using
Request::getVar('id');
for more you can check the link
Joomla plugin : how to get article title and article id
for jquery you can do like this. you can create a function and call on every page load it will sort all your content accordingly. you can assign other attributes also in foreach loop.
<div id="allArticles">
<article id="3">Article 3</article>
<article id="1">Article 1</article>
<article id="2">Article 2</article>
</div>
$("#allArticles article").sort(function (a, b) {
return parseInt(a.id) > parseInt(b.id);
}).each(function(){
var elem = $(this);
elem.remove();
$(elem).appendTo("#allArticles");
});
more you can see the working example here http://jsfiddle.net/THMu3/

Related

Restricting Slideshow CK to certain pages within Joomla

I am trying to show Slideshow CK only on the homepage of my Joomla based site. I have gone into the 'assignment' section of the module and restricted it to 'Home' menu item and said 'no' to include on child items. This works fine. I only see the slideshow on my homepage. However, I have created a link to an article on one of my other menus. When that article is displayed, it shows the slideshow. I want to suppress it when it jumps to that link. I have been playing with various options but without much joy. I would appreciate it if somebody can clarify the control mechanism for selectively displaying the slideshow.
I have found a method of overcoming the problem but someone may suggest a better approach. I specifically went and excluded certain selected articles in the assignments. I had tried to exclude a 'hidden' category but that did not work for me. The downside of my approach is that every time I introduce a new article I have to exclude it.
If I understand correctly you are creating articles without menu items. Without a menu item you won't be able to control the module assignment so easily.
If you're comfortable editing your template an lternative approach would be to amend the template and load the module.
Locate the index.php file of your template. You should be able to do this via the template manager.
Create a custom module position e.g. slideshow-ck and assign the slideshow module only to the homepage.
Then in the template you would need to add some PHP as follows:
<?php
$menu = $app->getMenu();
$active = $menu->getActive();
if ($menu->getActive() == $menu->getDefault('en-GB')) && $this->countModules('slideshow-ck') ?>
<jdoc:include type="modules" name="slideshow-ck" style="html5" />
<?php endif; ?>
Basically what that does is only load the module position if it's assigned to the menu item AND the user is currently viewing the homepage.
https://docs.joomla.org/How_to_determine_if_the_user_is_viewing_the_front_page

Page title showing up as site title on articles that do not have a menu item associated joomla 3.2

On all my Joomla pages I have the articles title as the h1 tag, so until now, Joomla has always displayed the title, i.e. what you see on the browser tab as the h1 tag. (There were one and the same thing).
However, this is not the case with all the pages that have no menu item linking to them, (they are linked to the rest of the site through another article). Here the name of my site is the page title.
How do I make the h1 tag the page title on these pages?
Try this,
This is happen due to those article pages meta options have title, Meta tag and keywords those are blank or not set yet. Then this case Joomla will read those info from your Global settings It may have your site name and Global description.
So the solution is set the Proper meta info for those articles from article manager.
If it is not practical then you can try it from article view or layout page Set meta data of Joomla page
Second Method is for setting the page title forcefully from scripts. It used for any components like here you have to check first method it will work for you..
Hope its Helps..
Problem solved! Here is how:
Make an override of com_content article and edit the default.php. Around lines 42/43 you should have the following code (the line number may not be exact as I have already taken out some code for a previous override):
<?php if ($params->get('show_title') || $params->get('show_author')) : ?>
Straight after that, add the following lines of code:
<?php $document=& JFactory::getDocument();
$document->setTitle( $this->item->title ); ?>

Joomla 3 Content Restriction

I have a single article and I want to display a portion of the content to the Registered user group only and the other portion to a Custom user group only.
I'm sure I read an article sometimes int he past year about doing this without a plugin (Though I may be mis-remembering the article)
Is this possible without an extension using something along these lines?
{content group=registered}
You can create a category (with limited access) say Registered. Create another category with restricted access say Paid_Access.
Now for every article create two articles - one in Registered category containing only Intro text and another full article in Paid_Access category.
Create Access Group and Access levels with same name
The hierarchy of the access levels will be as follows:
Public
Registered
Paid_Access
Set the Registered category to access level Registered. Set the Paid_Access category to access level Paid_Access
By default, on Joomla registration every user will be in Registered access level and will be able to only view article intro.
When user make some payment, move the user to Paid_Access access level. Users in this level can view the complete article.
Creating two articles for every new article may be cumbersome, to reduce this pain, you can create a custom form using ChronoForms. This form should have two text areas for the article - one would be for Intro text and another full article (without Intro text). The form while saving, will itself create two articles - one in Registered and another in Paid_Access. Thus your pain of creating two articles will be gone!
It is not possible without a plugin.
Reason : When Joomla is preparing content then there must be a function(code snipet) that detects the Text enclosed in {content} tags and decide what to do with this text and accordingly edits the content.
I have developed a Content Plugin, This will helps you https://github.com/jitendra-khatri/jcontenthider to setup your scenario.
You could do this with CSS if your template adds the access level as a class on the body or html (mine do). Though anyone with firebug or a code inspector could unhide content if they thought to look at the source.
<body class="registered">
// other code up to article content
<div id="articleContent">
// this is now in your article
<div class="hidefrompaid">
// content for registered users
</div>
<div class="hidefromregistered">
// content for paid users
</div>
</div>
...
Then your css would be:
body.registered .hidefromregistered {
display:none;
}
body.paid .hidefrompaid {
display:none;
}
Or if you really want to not show it you could use jQuery to delete the text the user should not see using those same css classed wrappers around the text.
jQuery('body.registered').find('.hidefromregistered').remove();
jQuery('body.paid').find('.hidefrompaid').remove();
I ended up using the jContentHider plugin. While I still had do some work arounds, I got it working the way I want to.
For others interested:
jContentHider on GitHub

Joomla: Override Category Blog output multiple times?

Yes. I want to override output of Category Blog component to 2 different display styles.
For first style, i copied and edited blog_item.php & blog.php in [mytemplate]/html folder. Then i choose template style from dropdown in backend of my category blog. That's worked. The display of category blog change as i expected.
But if i want to create another style and use in another category blog. How could i do ? And how to i named my files ( I tried blog_1.php, blog_item_1.php ) but only see my first style display in backend.
I'm using joomla 2.5.
Please help me. Thank you very much !
=================================================================================
[UPDATED]
I solved this issue. Here my solution:
Clone my template to [my_template_2]
Go to [my_template_2]/html/com_content/category then edit blog.php, blog_item.php as my needs.
Go to backend, at my category blog menuitem, i assigned [my_template_2] as its template style.
Then it worked. Both my category blog have its own style.
This maybe not very good solution because i have to use multiple templates, but at this time it's quite enough for me.
Thank you, stackoverflowers.
=================================================================================
[UPDATED 2]
Now, with multiple template styles, I could create unlimited styles for my category blog component within just only one template. That's very much better.
As you may know, joomla doesn't let developers make different styles for its components.
I think you have to list all menus which are made by "category blog component" in template managing page and let users set each menu style at there.**
and at blog.php, check template setting and then load customized style...
** you have to develop a custom field element which list all "category blog component" menus.
* you can use this code to accessing template parameters in component's template :
$app =& JFactory::getApplication();
$template = $app->getTemplate(true);
$paramsTemplate = $template->params;
$style = $paramsTemplate->get('style');
You don't need to use multiple styles. What you need is to use alternate layouts and alternative menu layouts.
For alternative menu layouts in the html/componentname/category folder of your template make a new style with a unique set of names similar to the way blog already provides an alternative to category list in the article category layout folder. Also make a new xml file for each layout that you make, with a matching name.
When you create your menu item you will now get these alternatives along with your other normal choices. Just select the one you want.
Based on the learnings above here is my code for the /templates/mytheme/com_content/category/blog.php
And then in the Global Configuration > Article Manager Options > Category choose Blog as the override/ layout.
defined('_JEXEC') or die;
JHtml::addIncludePath(JPATH_COMPONENT.'/helpers');
$pageclass_sfx = trim($this->pageclass_sfx);
// so pick it on the page class in menu item
if (isset($pageclass_sfx) && $pageclass_sfx != '') {
echo $this->loadTemplate($pageclass_sfx);
} else {
echo $this->loadTemplate('default');
}
I can add multiple elseif if something else is needed, or it will look for 'blog_' . $this->pageclass_sfx . 'php'. It is always beginning blog_ as thats coded into the com_content. The old blog i moved to blog_default.php and blog_default_item.php

assign image to category and it's posts on WordPress

I want to assign an image to a category and it's posts on WordPress. When adding the new post it will take the image and assign to it's container category. If you have any way to help or plug-in to do that, I would be really grateful.
Based on your question, I think you are trying to show posts (or maybe post excerpts) from multiple categories in a single list and include images in these posts based on their individual categories.
If there is only one place you are trying to display these images and if they will not change very often, you could include some conditionals directly in The Loop.
<!-- Test to see if the post is in a given cat and apply a custom class for styling -->
<?php if ( in_category('CATNUMBER') ) { ?>
<div class="SOME-CUSTOM-STYLE">
<?php } else { ?>
<div class="GENERIC-NON-STYLED-POST">
<?php } ?>
Once you have custom classes on the divs by category number, you can style a background image in your CSS. Alternately, you could spit out an tag right in the loop.
If you foresee adding new categories and/or changing pictures often, you will probably want a cleaner way of doing this. If you only have a handful of categories or if you are comfortable making changes to the loop often, this would work fine.

Resources