Использование параметров в модуле
рейтинг: 8.8/10, голосов: 22
Как вы уже могли заметить, практически все модули имеют настройки, параметры. Так, например, стандартный модуль Навигатор имеет такие настройки как Показать главную, Разделитель текста и прочее. Наш модуль может быть ни чем не хуже. Добавим в пример модуля из предыдущего раздела несколько настроек.
Итак, например мы хотим создать модуль который будет приветствовать пользователя по имени, либо просто общее сообщение для гостей. Для этого в настройках должно быть определено два сообщения. Параметры модуля будем определять в файле XML с использованием готового набора параметров в Joomla. Выглядит это все следующим образом:
<?xml version="1.0" encoding="utf-8"?>
<install type="module" version="1.5.0">
<name>testmodule3</name>
<author>Joomla-book.ru</author>
<version>1.0</version>
<description>TEST #3 Joomla-book.ru module</description>
<files>
<filename module="mod_testmodule3">mod_testmodule3.php</filename>
</files>
<params>
<param name="saluteguest" type="text" default="Hello stranger" label="gsalute" description="Salute text for guests" />
<param name="saluteregistered" type="text" default="Welcome" label="rsalute" description="Salute text for registered users" />
</params>
</install>
Таким образом мы объявим два текстовых поля (одно строчных). В панели администратора это будет выглядеть примерно так:

А в следующем листинге мы получим значение установленных настроек в коде нашего модуля
<?php
defined('_JEXEC') or die('Restricted access');
$user = JFactory::getUser();
// Получаем установленные параметры
$saluteg = $params->get("saluteguest");
$saluter = $params->get("saluteregistered");
// В зависимости от типа посетителя сайта, выводим сообщение
if ($user->guest) {
echo "<p>$saluteg</p>";
} else {
echo "<p>$saluter</p>";
}
?>
Следующим шагом, расширим параметры нашего модуля полем типа textarea, и переключателем со значениями Да и Нет.
<params>
<param name="tosalute" type="radio" default="1" label="Salute users?" >
<option value="0">No</option>
<option value="1">Yes</option>
</param>
<param name="saluteguest" type="textarea" default="" rows="4" cols="40" label="Guest users salute" description="Salute text for guests" />
<param name="saluteregistered" type="textarea" default="" rows="4" cols="40" label="Registered users salute" description="Salute text for registered users" />
</params>
Выглядит это следующим образом

Использование настроек модуля в php для других типов настроек ничем не отличается:
<?php
defined('_JEXEC') or die('Restricted access');
$user = JFactory::getUser();
// Получаем значения настроек
$tosalute = $params->get("tosalute");
$saluteg = $params->get("saluteguest");
$saluter = $params->get("saluteregistered");
if ($tosalute) {
if ($user->guest) echo "<p>$saluteg</p>";
else echo "<p>$saluter</p>";
}
?>
Каким образом можно сделать список с множественным выбором в качестве параметра? Нужно, чтобы в админке можно было выбрать несколько взятых из базы названий. Где про это почитать? (можно по-английски)
Что-то под 1.7 не работает пример.
Что тут надо поправить?
XML файл будет выглядеть немного по-другому для Joomla 1.7
Подскажите пожалуйста а как добавить в модуль текстовый редактор по типу как сделано в модуле mod_custom?
Все просто, описал как это делается slovu.net/coding/joomla/1057-rasshiryaem-nastrojki-modulya-dobavlyaem-tekstovyj-redaktor-kak-v-module-mod-custom
Отличная инфа, очень помогло!
Добрый день.
Вопрос - есть ли какие то нюансы при работе с Joomla 3.0. Или же данный урок подходит для сей CMS без каких бы то нибыло изменений?
Доброго времени суток. Подскажите пожалуйста как получить значение например из email
<field name="email"
type="text"
default=""
label="EMAIL"
description="EMAIL">
</field>
если в modules/modules_mod/tmpl/default.php
вставить echo $email; то выведет значение. А если для отправки почты я использую отдельный файл. Как в нем получить значение?
I see your site needs some fresh & unique content.
Writing manually is time consuming, but there is solution for this.
Just search for: Masquro's strategies
Hi to all, since I am in fact keen of reading this website's post to
be updated on a regular basis. It contains nice stuff.
срочно оформление визы
в мексику
нотариально заверенная доверенность на курьера в болгарию что
это такое
It's an awesome paragraph in support of all the online viewers; they will take advantage from it I
am sure.
T?ere are 2 types of solar powered wwater heaters,
and they ?re general?y flat plate collectors аnd evacuated tube water heaters.
Уou ?оn't nedd to concern yo?rself with utility
companies сonstantly raising tthe costs оf youг rspective propane or electricity iif уоu
?ѕe solar energy t? heat ?o?r home'ѕ water.
T?еse systems heat th? lake ?y usіng passsing watewr wіt? solar collectors ?pon t?e roof of the hоme.
At this time it sounds like BlogEngine is the best blogging platform out there right now.
(from what I've read) Is that what you are using
on your blog?
Hi! Do you use Twitter? I'd like to follow you if that would be okay.
I'm undoubtedly enjoying your blog and look forward to new posts.
I have read so many content regarding the blogger lovers but this article is really a
nice paragraph, keep it up.
Howdy would you mind letting me know which webhost you're
utilizing? I've loaded your blog in 3 different internet browsers and I must
say this blog loads a lot faster then most. Can you suggest a good internet
hosting provider at a fair price? Cheers, I appreciate it!
Have you ever thought about including a little bit more than just your articles?
I mean, what you say is important and everything. However think about if you added some great
graphics or videos to give your posts more, "pop"!
Your content is excellent but with images and video clips, this
site could certainly be one of the most beneficial in its niche.
Wonderful blog!
Awesome blog! Is your theme custom made or did you download it
from somewhere? A design like yours with a few simple tweeks would
really make my blog shine. Please let me know where you got your theme.
Bless you
I constantly spent my half an hour to read this weblog's content everyday along with a
mug of coffee.
Normally I do not read article on blogs, but I would like to say that
this write-up very forced me to take a look at and do it!
Your writing style has been surprised me. Thanks, very
nice post.
Fantastic beat ! I would like to apprentice while you
amend your website, how could i subscribe for a blog website?
The account helped me a acceptable deal. I had been a little bit acquainted of this your broadcast provided bright
clear concept
What i do not realize is if truth be told how you're no longer actually much more smartly-liked than you might be
right now. You're so intelligent. You understand therefore significantly in terms of this subject,
made me for my part imagine it from a lot of numerous angles.
Its like women and men aren't fascinated
except it is something to accomplish with Lady gaga!
Your personal stuffs nice. At all times maintain it up!
There's definately a lot to learn about this topic. I like
all of the points you've made.
Awesome! Its in fact awesome piece of writing,
I have got much clear idea on the topic of from this paragraph.
Very descriptive post, I loved that bit. Will there be a part 2?
It's really very complicated in this busy life to listen news on Television, thus I just use web for that reason, and obtain the
most recent news.
Peculiar article, exactly what I needed.
Hello there, I discovered your web site via Google while looking for a related subject,
your website came up, it looks good. I have bookmarked it in my google bookmarks.
Hi there, just was alert to your blog thru Google, and located that it's truly informative.
I am gonna watch out for brussels. I will appreciate in the event you proceed this in future.
Many other people can be benefited out of your writing. Cheers!
Hi there to every single one, it's genuinely a pleasant for
me to pay a quick visit this site, it contains useful Information.
Its such as you learn my mind! You seem to grasp so much about this, like you wrote the book in it or something.
I feel that you just could do with a few p.c. to force the message house a little bit, however instead
of that, this is excellent blog. An excellent read.
I will certainly be back.
This post is priceless. How can I find out more?
Amazing! Its genuinely awesome article, I have got much clear idea regarding from
this paragraph.
If you desire to grow your familiarity simply keep visiting this site and be updated with the latest information posted here.
Основные и альтернативные способы Париматч регистрации
Everyone loves it when people come together and share
thoughts. Great site, continue the good work!
Tremendous things here. I'm very happy to see your post.
Thank you so much and I'm taking a look ahead to touch you.
Will you please drop me a mail?
Please let me know if you're looking for a writer
for your weblog. You have some really good articles and I believe I would be a good asset.
If you ever want to take some of the load off, I'd absolutely love to
write some content for your blog in exchange for a link back to mine.
Please shoot me an email if interested. Cheers!
Great article.
Greetings! Quick question that's totally off topic.
Do you know how to make your site mobile friendly? My web site looks
weird when viewing from my iphone4. I'm trying to find a template or plugin that might
be able to correct this problem. If you have any suggestions, please share.
Thank you!
Great post. I used to be checking continuously this weblog and I'm impressed!
Very helpful information specially the closing part :) I handle such info much.
I was seeking this particular info for a very long
time. Thanks and best of luck.
Hello! I could have sworn I've been to this blog before but after going through many of the posts I realized it's
new to me. Anyways, I'm certainly delighted I discovered it and I'll be book-marking it and checking
back often!
Thank you for the good writeup. It in fact was a amusement account
it. Look advanced to far added agreeable from you!
By the way, how could we communicate?
Incredible points. Great arguments. Keep up the good work.
My family every time say that I am wasting my time here
at net, but I know I am getting knowledge everyday by reading such nice articles or reviews.
Thank you for any other informative web site.
Where else may I am getting that kind of info
written in such an ideal means? I've a venture that I'm simply now operating on, and I've been at the look out for
such information.
Someone essentially assist to make significantly
articles I'd state. That is the first time I frequented your web page and to this point?
I surprised with the analysis you made to make this actual submit incredible.
Great job!
It's enormous that you are getting ideas from this post as well as from our dialogue made at this
place.
For latest news you have to pay a visit internet and on internet I found this web site as a most excellent web site for most up-to-date updates.
I loved as much as you'll receive carried out right here.
The sketch is attractive, your authored subject matter stylish.
nonetheless, you command get got an shakiness over that you wish be delivering the
following. unwell unquestionably come more formerly again as exactly the same
nearly a lot often inside case you shield this increase.
Awesome article.
Hi there! I understand this is sort of off-topic
however I had to ask. Does managing a well-established
website like yours require a lot of work? I'm brand new to running a blog but I do write in my diary on a daily basis.
I'd like to start a blog so I can share my experience and
feelings online. Please let me know if you have any kind of suggestions or tips for
brand new aspiring blog owners. Thankyou!
Good blog post. I certainly appreciate this website.
Keep writing!
I've learn some just right stuff here. Certainly value bookmarking for revisiting.
I wonder how so much attempt you set to make this sort of magnificent informative web
site.
Great blog! Do you have any suggestions for aspiring writers?
I'm planning to start my own site soon but I'm a little lost on everything.
Would you recommend starting with a free platform like Wordpress or go for a paid option? There are
so many options out there that I'm totally confused ..
Any ideas? Thank you!
Hi there very cool web site!! Man .. Beautiful .. Wonderful ..
I'll bookmark your blog and take the feeds also?
I'm satisfied to seek out numerous useful information here in the
publish, we want develop more strategies on this regard,
thanks for sharing. . . . . .
Hi, its pleasant article on the topic of media print, we all be
aware of media is a impressive source of information.
Your style is unique compared to other people I've read stuff from.
Thank you for posting when you have the opportunity,
Guess I will just bookmark this blog.
Appreciate this post. Will try it out.
You're so awesome! I do not think I have read through anything like that before.
So good to discover somebody with some unique thoughts on this subject matter.
Really.. many thanks for starting this up. This site is
something that is required on the internet, someone with a bit of originality!
Hi there, I discovered your website through Google whilst in search
of a comparable topic, your website got here up, it is apparently like great.
We have bookmarked it within my google bookmarks.
Heya i'm for the primary time here. I came across this board and I
to find It truly useful & it helped me out a lot. I hope to offer something
again and help others like you helped me.
This is a topic that's near to my heart... Thanks a lot!
Just where are your information though?
A remarkable discussion is definitely worth comment.
There's certainly that that you have to write
more about this subject, it may not be considered a taboo matter
but usually people don't focus on such subjects. To the next!
Thanks a lot!!
Hey there I am so delighted I found your site, I really found
you by mistake, while I was looking on Digg for something else, Regardless I
am here now and would just like to say thanks for a fantastic post
and a all round exciting blog (I also love the theme/design), I don?t have time to read through
it all at the moment but I have bookmarked it and also included your RSS feeds,
so when I have time I will be back to read a great deal more, Please do keep up the awesome jo.
Have you ever thought about including a little
bit more than merely your content? I mean, the things you say is important and all.
But imagine if you added some very nice photos or videos to give your posts more, "pop"!
Your articles is excellent but with images and video clips, this site could certainly be one of several best in their field.
Very good blog!
Hi my friend! I want to point out that this
post is awesome, great written and have almost
all vital infos. I'd like to find out more posts like this .
Heya i am just for the first time here. I found
this board and I discover it truly useful & it helped me out much.
I really hope to provide something back and aid others such as you
helped me.
Hi there, just became alert to your weblog thru Google,
and located that it's truly informative. I'm likely to be cautious
for brussels. I'll be grateful when you proceed this in future.
Plenty of others could possibly be benefited through your writing.
Cheers!
Your style is very unique in comparison to others I actually have read stuff from.
Thanks a lot for posting if you have the chance, Guess I'll just book mark this site.
Hey very nice blog!! Guy .. Excellent .. Wonderful .. I will bookmark your web site and
take the feeds also? I am happy to find a lot of useful
information right here in the post, we'd like develop extra strategies on this regard, thank you for sharing.
. . . . .
Hurrah! At last I bought a webpage from which I have the capacity
to in fact obtain helpful facts regarding my study and knowledge.
This web site definitely has all the information I needed concerning
this subject and didn't know who to ask.
Hello! I realize this is somewhat off topic nevertheless i was wondering when you knew where I really could
locate a captcha plugin for my comment form? I'm utilizing
the same blog platform as yours and I'm having trouble finding one?
Thanks a good deal!
I am not positive the spot you are getting the info, but great topic.
I must spend a bit of time learning much more or understanding more.
Thanks for excellent information I used to
be trying to find this info for my mission.
With havin a lot written content have you ever come upon any issues of plagorism
or copyright infringement? My blog has a lot
of completely unique content I've either written myself or outsourced however it
looks like a lot of it is popping it up all over
the web without my agreement. Have you figured out any methods to help you protect against content from being stolen? I'd really appreciate it.
I always accustomed to study bit of writing in news papers the good news
is while i am an end user of web therefore from now I am using net for articles, because
of web.
Howdy! I really could have sworn I've been to this website
before but after browsing through a number of the post I realized it's new to me.
Anyways, I'm definitely glad I discovered it
and I'll be bookmarking and checking back often!
Hey! I know this is kinda off topic nevertheless I'd figured I'd ask.
Would you be interested in exchanging links or maybe
guest authoring a blog post or vice-versa? My site addresses a lot of the same subjects as yours and I think
we could greatly benefit from each other. If you happen to be
interested feel free to shoot me an email. I look forward to hearing from you!
Excellent blog by the way!
I'm curious to determine what blog system you possess been using?
I'm experiencing some minor security problems with my latest website
and I would like to find some thing risk-free.
Have you got any recommendations?
magnificent put up, very informative. I wonder why the contrary specialists with
this sector tend not to notice this. You should proceed your writing.
I'm sure, you have a fantastic readers' base already!
We're a gaggle of volunteers and starting a new scheme in our community.
Your website provided us with helpful information to operate on. You've performed a
formidable task and our whole community will likely be thankful to you.
It's very straightforward to determine any matter on net when compared with textbooks, because i
found this article around this internet site.
It's an amazing component of writing for every one of the web
visitors; they may get benefit from it I am sure.
bookmarked!!, I really like your internet site!
As the admin of this site is working, no doubt very rapidly it will
be famous, due to its feature contents.
I'm not sure where you're getting your info, but good topic.
I needs to spend some time learning much more or
understanding more. Thanks for wonderful info I was looking for this information for my mission.
I got this web site from my pal who shared with me concerning this web page and at the moment
this time I am browsing this web site and reading very informative
articles or reviews at this time.
If some one wants to become updated with latest technologies afterward he must
be pay a fast visit this website and be current at all times.
hi!,I love your writing very much! percentage we stay in contact extra
about your post on AOL? I require a professional within this space to eliminate my problem.
Can be that's you! Taking a look ahead to peer you.
Just want to say your article is as surprising.
The clearness to your post is simply nice and that i can suppose you're an expert on this subject.
Fine together with your permission let me to take hold of your feed to keep updated with drawing close post.
Thanks a million and please continue the rewarding
work.
What's up, I check your new stuff regularly.
Your writing style is awesome, keep in the good work!
I think this is among the most important info for me.
And i'm glad reading your article. But should remark on few
general things, The website style is great, the articles is
really excellent : D. Good job, cheers 0mniartist asmr
First of all I want to say fantastic blog! I had a quick question that
I'd like to ask if you don't mind. I was curious to
find out how you center yourself and clear your head prior to writing.
I've had a difficult time clearing my thoughts in getting my
thoughts out. I truly do enjoy writing however it just seems like the first 10 to 15 minutes are lost
just trying to figure out how to begin. Any recommendations
or tips? Cheers! 0mniartist asmr
What's up to every body, it's my first pay a visit of this blog; this blog includes remarkable and truly fine information in favor of
readers. asmr 0mniartist
This is the perfect blog for everyone who wishes to understand
this topic. You know a whole lot its almost hard to argue with you (not that I personally will need to…HaHa).
You definitely put a brand new spin on a subject which has been discussed
for years. Great stuff, just excellent! 0mniartist asmr